From edbea30cfc1d641acb9c7ca71b516b5a3192a5a8 Mon Sep 17 00:00:00 2001 From: Andrew Roth Date: Tue, 11 Dec 2018 08:55:26 -0500 Subject: [PATCH] Fix #187 for windows compatibility (#207) * Added ability to choose local-exec interpreter * Remove accidental extra file * formatting --- CHANGELOG.md | 2 +- README.md | 68 +++++++++++++++++++++++++++------------------------- aws_auth.tf | 3 ++- variables.tf | 6 +++++ 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46aa7d1..1cbff0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Added -- Write your awesome addition here (by @you) +- Added ability to choose local-exec interpreter (by @rothandrew) ### Changed diff --git a/README.md b/README.md index 9ec8d74..fef1985 100644 --- a/README.md +++ b/README.md @@ -101,44 +101,46 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| cluster_create_timeout | Timeout value when creating the EKS cluster. | string | `15m` | no | -| cluster_delete_timeout | Timeout value when deleting the EKS cluster. | string | `15m` | no | -| cluster_name | Name of the EKS cluster. Also used as a prefix in names of related resources. | string | - | yes | -| cluster_security_group_id | If provided, the EKS cluster will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the workers and provide API access to your current IP/32. | string | `` | no | -| cluster_version | Kubernetes version to use for the EKS cluster. | string | `1.10` | no | -| config_output_path | Where to save the Kubectl config file (if `write_kubeconfig = true`). Should end in a forward slash `/` . | string | `./` | no | -| kubeconfig_aws_authenticator_additional_args | Any additional arguments to pass to the authenticator such as the role to assume. e.g. ["-r", "MyEksRole"]. | list | `` | no | -| kubeconfig_aws_authenticator_command | Command to use to to fetch AWS EKS credentials. | string | `aws-iam-authenticator` | no | -| kubeconfig_aws_authenticator_env_variables | Environment variables that should be used when executing the authenticator. e.g. { AWS_PROFILE = "eks"}. | map | `` | no | -| kubeconfig_name | Override the default name used for items kubeconfig. | string | `` | no | -| manage_aws_auth | Whether to write and apply the aws-auth configmap file. | string | `true` | no | -| map_accounts | Additional AWS account numbers to add to the aws-auth configmap. See examples/eks_test_fixture/variables.tf for example format. | list | `` | no | -| map_roles | Additional IAM roles to add to the aws-auth configmap. See examples/eks_test_fixture/variables.tf for example format. | list | `` | no | -| map_users | Additional IAM users to add to the aws-auth configmap. See examples/eks_test_fixture/variables.tf for example format. | list | `` | no | +| cluster\_create\_timeout | Timeout value when creating the EKS cluster. | string | `15m` | no | +| cluster\_delete\_timeout | Timeout value when deleting the EKS cluster. | string | `15m` | no | +| cluster\_name | Name of the EKS cluster. Also used as a prefix in names of related resources. | string | - | yes | +| cluster\_security\_group\_id | If provided, the EKS cluster will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the workers and provide API access to your current IP/32. | string | `` | no | +| cluster\_version | Kubernetes version to use for the EKS cluster. | string | `1.10` | no | +| config\_output\_path | Where to save the Kubectl config file (if `write_kubeconfig = true`). Should end in a forward slash `/` . | string | `./` | no | +| kubeconfig\_aws\_authenticator\_additional\_args | Any additional arguments to pass to the authenticator such as the role to assume. e.g. ["-r", "MyEksRole"]. | list | `` | no | +| kubeconfig\_aws\_authenticator\_command | Command to use to to fetch AWS EKS credentials. | string | `aws-iam-authenticator` | no | +| kubeconfig\_aws\_authenticator\_command\_args | Default arguments passed to the authenticator command. Defaults to [token -i $cluster_name]. | list | `` | no | +| kubeconfig\_aws\_authenticator\_env\_variables | Environment variables that should be used when executing the authenticator. e.g. { AWS_PROFILE = "eks"}. | map | `` | no | +| kubeconfig\_name | Override the default name used for items kubeconfig. | string | `` | no | +| local\_exec\_interpreter | Command to run for local-exec resources. Must be a shell-style interpreter. If you are on Windows Git Bash is a good choice. Defaults to ["/bin/sh", "-c"] | list | `` | no | +| manage\_aws\_auth | Whether to write and apply the aws-auth configmap file. | string | `true` | no | +| map\_accounts | Additional AWS account numbers to add to the aws-auth configmap. See examples/eks_test_fixture/variables.tf for example format. | list | `` | no | +| map\_roles | Additional IAM roles to add to the aws-auth configmap. See examples/eks_test_fixture/variables.tf for example format. | list | `` | no | +| map\_users | Additional IAM users to add to the aws-auth configmap. See examples/eks_test_fixture/variables.tf for example format. | list | `` | no | | subnets | A list of subnets to place the EKS cluster and workers within. | list | - | yes | | tags | A map of tags to add to all resources. | map | `` | no | -| vpc_id | VPC where the cluster and workers will be deployed. | string | - | yes | -| worker_additional_security_group_ids | A list of additional security group ids to attach to worker instances | list | `` | no | -| worker_group_count | The number of maps contained within the worker_groups list. | string | `1` | no | -| worker_groups | A list of maps defining worker group configurations. See workers_group_defaults for valid keys. | list | `` | no | -| worker_security_group_id | If provided, all workers will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the EKS cluster. | string | `` | no | -| worker_sg_ingress_from_port | Minimum port number from which pods will accept communication. Must be changed to a lower value if some pods in your cluster will expose a port lower than 1025 (e.g. 22, 80, or 443). | string | `1025` | no | -| workers_group_defaults | Override default values for target groups. See workers_group_defaults_defaults in locals.tf for valid keys. | map | `` | no | -| write_kubeconfig | Whether to write a Kubectl config file containing the cluster configuration. Saved to `config_output_path`. | string | `true` | no | +| vpc\_id | VPC where the cluster and workers will be deployed. | string | - | yes | +| worker\_additional\_security\_group\_ids | A list of additional security group ids to attach to worker instances | list | `` | no | +| worker\_group\_count | The number of maps contained within the worker_groups list. | string | `1` | no | +| worker\_groups | A list of maps defining worker group configurations. See workers_group_defaults for valid keys. | list | `` | no | +| worker\_security\_group\_id | If provided, all workers will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the EKS cluster. | string | `` | no | +| worker\_sg\_ingress\_from\_port | Minimum port number from which pods will accept communication. Must be changed to a lower value if some pods in your cluster will expose a port lower than 1025 (e.g. 22, 80, or 443). | string | `1025` | no | +| workers\_group\_defaults | Override default values for target groups. See workers_group_defaults_defaults in locals.tf for valid keys. | map | `` | no | +| write\_kubeconfig | Whether to write a Kubectl config file containing the cluster configuration. Saved to `config_output_path`. | string | `true` | no | ## Outputs | Name | Description | |------|-------------| -| cluster_certificate_authority_data | Nested attribute containing certificate-authority-data for your cluster. This is the base64 encoded certificate data required to communicate with your cluster. | -| cluster_endpoint | The endpoint for your EKS Kubernetes API. | -| cluster_id | The name/id of the EKS cluster. | -| cluster_security_group_id | Security group ID attached to the EKS cluster. | -| cluster_version | The Kubernetes server version for the EKS cluster. | -| config_map_aws_auth | A kubernetes configuration to authenticate to this EKS cluster. | +| cluster\_certificate\_authority\_data | Nested attribute containing certificate-authority-data for your cluster. This is the base64 encoded certificate data required to communicate with your cluster. | +| cluster\_endpoint | The endpoint for your EKS Kubernetes API. | +| cluster\_id | The name/id of the EKS cluster. | +| cluster\_security\_group\_id | Security group ID attached to the EKS cluster. | +| cluster\_version | The Kubernetes server version for the EKS cluster. | +| config\_map\_aws\_auth | A kubernetes configuration to authenticate to this EKS cluster. | | kubeconfig | kubectl config file contents for this EKS cluster. | -| worker_iam_role_arn | default IAM role ARN for EKS worker groups | -| worker_iam_role_name | default IAM role name for EKS worker groups | -| worker_security_group_id | Security group ID attached to the EKS workers. | -| workers_asg_arns | IDs of the autoscaling groups containing workers. | -| workers_asg_names | Names of the autoscaling groups containing workers. | +| worker\_iam\_role\_arn | default IAM role ARN for EKS worker groups | +| worker\_iam\_role\_name | default IAM role name for EKS worker groups | +| worker\_security\_group\_id | Security group ID attached to the EKS workers. | +| workers\_asg\_arns | IDs of the autoscaling groups containing workers. | +| workers\_asg\_names | Names of the autoscaling groups containing workers. | diff --git a/aws_auth.tf b/aws_auth.tf index 0d31254..7a559fa 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -8,7 +8,8 @@ resource "null_resource" "update_config_map_aws_auth" { depends_on = ["aws_eks_cluster.this"] provisioner "local-exec" { - command = "for i in {1..5}; do kubectl apply -f ${var.config_output_path}config-map-aws-auth_${var.cluster_name}.yaml --kubeconfig ${var.config_output_path}kubeconfig_${var.cluster_name} && break || sleep 10; done" + command = "for i in {1..5}; do kubectl apply -f ${var.config_output_path}config-map-aws-auth_${var.cluster_name}.yaml --kubeconfig ${var.config_output_path}kubeconfig_${var.cluster_name} && break || sleep 10; done" + interpreter = ["${var.local_exec_interpreter}"] } triggers { diff --git a/variables.tf b/variables.tf index 48a3cb7..6982097 100644 --- a/variables.tf +++ b/variables.tf @@ -134,3 +134,9 @@ variable "cluster_delete_timeout" { description = "Timeout value when deleting the EKS cluster." default = "15m" } + +variable "local_exec_interpreter" { + description = "Command to run for local-exec resources. Must be a shell-style interpreter. If you are on Windows Git Bash is a good choice. Defaults to [\"/bin/sh\", \"-c\"]" + type = "list" + default = ["/bin/sh", "-c"] +}