Skip to content

Commit de5417d

Browse files
authored
Fix authentication action. Don't use map variable for authentication action (#4)
1 parent 7678afa commit de5417d

File tree

8 files changed

+179
-76
lines changed

8 files changed

+179
-76
lines changed

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ We suggest creating a personal access token for a GitHub bot user with the follo
108108
## Usage
109109

110110

111+
**IMPORTANT:** The `master` branch is used in `source` just as an example. In your code, do not pin to `master` because there may be breaking changes between releases.
112+
Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest releases](https://github.com/cloudposse/terraform-aws-ecs-atlantis/releases).
113+
114+
115+
111116
Module usage examples:
112117

113118
- [without authentication](examples/without_authentication) - complete example without authentication
@@ -119,7 +124,7 @@ Module usage examples:
119124

120125
```
121126
module "atlantis" {
122-
source = "git::https://github.com/cloudposse/terraform-aws-ecs-atlantis.git?ref=master"
127+
source = "git::https://github.com/cloudposse/terraform-aws-ecs-atlantis.git?ref=master"
123128
enabled = "true"
124129
name = "${var.name}"
125130
namespace = "${var.namespace}"
@@ -132,7 +137,6 @@ module "atlantis" {
132137
133138
alb_arn_suffix = "${module.alb.alb_arn_suffix}"
134139
alb_dns_name = "${module.alb.alb_dns_name}"
135-
alb_listener_arns = ["${module.alb.listener_arns}"]
136140
alb_name = "${module.alb.alb_name}"
137141
alb_zone_id = "${module.alb.alb_zone_id}"
138142
@@ -144,6 +148,12 @@ module "atlantis" {
144148
private_subnet_ids = ["${module.subnets.private_subnet_ids}"]
145149
security_group_ids = ["${module.vpc.vpc_default_security_group_id}"]
146150
vpc_id = "${module.vpc.vpc_id}"
151+
152+
alb_ingress_unauthenticated_listener_arns = ["${module.alb.listener_arns}"]
153+
alb_ingress_unauthenticated_listener_arns_count = 2
154+
alb_ingress_unauthenticated_paths = ["/*"]
155+
alb_ingress_listener_unauthenticated_priority = "100"
156+
alb_ingress_authenticated_paths = []
147157
}
148158
```
149159

@@ -169,13 +179,15 @@ Available targets:
169179
| alb_arn_suffix | The ARN suffix of the ALB | string | - | yes |
170180
| alb_dns_name | DNS name of ALB | string | - | yes |
171181
| alb_ingress_authenticated_hosts | Authenticated hosts to match in Hosts header (a maximum of 1 can be defined) | list | `<list>` | no |
182+
| alb_ingress_authenticated_listener_arns | A list of authenticated ALB listener ARNs to attach ALB listener rules to | list | `<list>` | no |
183+
| alb_ingress_authenticated_listener_arns_count | The number of authenticated ARNs in `alb_ingress_authenticated_listener_arns`. This is necessary to work around a limitation in Terraform where counts cannot be computed | string | `0` | no |
172184
| alb_ingress_authenticated_paths | Authenticated path pattern to match (a maximum of 1 can be defined) | list | `<list>` | no |
173185
| alb_ingress_listener_authenticated_priority | The priority for the rules with authentication, between 1 and 50000 (1 being highest priority). Must be different from `alb_ingress_listener_unauthenticated_priority` since a listener can't have multiple rules with the same priority | string | `100` | no |
174186
| alb_ingress_listener_unauthenticated_priority | The priority for the rules without authentication, between 1 and 50000 (1 being highest priority). Must be different from `alb_ingress_listener_authenticated_priority` since a listener can't have multiple rules with the same priority | string | `50` | no |
175187
| alb_ingress_unauthenticated_hosts | Unauthenticated hosts to match in Hosts header (a maximum of 1 can be defined) | list | `<list>` | no |
188+
| alb_ingress_unauthenticated_listener_arns | A list of unauthenticated ALB listener ARNs to attach ALB listener rules to | list | `<list>` | no |
189+
| alb_ingress_unauthenticated_listener_arns_count | The number of unauthenticated ARNs in `alb_ingress_unauthenticated_listener_arns`. This is necessary to work around a limitation in Terraform where counts cannot be computed | string | `0` | no |
176190
| alb_ingress_unauthenticated_paths | Unauthenticated path pattern to match (a maximum of 1 can be defined) | list | `<list>` | no |
177-
| alb_listener_arns | A list of ALB listener ARNs | list | - | yes |
178-
| alb_listener_arns_count | Number of elements in the list of ALB Listener ARNs for the ECS service | string | `2` | no |
179191
| alb_name | The Name of the ALB | string | - | yes |
180192
| alb_target_group_alarms_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an ALARM state from any other state. | list | `<list>` | no |
181193
| alb_target_group_alarms_insufficient_data_actions | A list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an INSUFFICIENT_DATA state from any other state. | list | `<list>` | no |
@@ -192,7 +204,16 @@ Available targets:
192204
| atlantis_wake_word | Wake world for Atlantis | string | `atlantis` | no |
193205
| atlantis_webhook_format | Template for the Atlantis webhook URL which is populated with the hostname | string | `https://%s/events` | no |
194206
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
195-
| authentication_action | Authentication action to be placed in front of all other ALB listener actions to authenticate users with Cognito or OIDC. Required when `alb_ingress_authenticated_hosts` or `alb_ingress_authenticated_paths` are provided | map | `<map>` | no |
207+
| authentication_cognito_user_pool_arn | Cognito User Pool ARN | string | `` | no |
208+
| authentication_cognito_user_pool_client_id | Cognito User Pool Client ID | string | `` | no |
209+
| authentication_cognito_user_pool_domain | Cognito User Pool Domain. The User Pool Domain should be set to the domain prefix (`xxx`) instead of full domain (https://xxx.auth.us-west-2.amazoncognito.com) | string | `` | no |
210+
| authentication_oidc_authorization_endpoint | OIDC Authorization Endpoint | string | `` | no |
211+
| authentication_oidc_client_id | OIDC Client ID | string | `` | no |
212+
| authentication_oidc_client_secret | OIDC Client Secret | string | `` | no |
213+
| authentication_oidc_issuer | OIDC Issuer | string | `` | no |
214+
| authentication_oidc_token_endpoint | OIDC Token Endpoint | string | `` | no |
215+
| authentication_oidc_user_info_endpoint | OIDC User Info Endpoint | string | `` | no |
216+
| authentication_type | Authentication type. Supported values are `COGNITO`, `OIDC`, `NONE` | string | `NONE` | no |
196217
| autoscaling_max_capacity | Atlantis maximum tasks to run | string | `1` | no |
197218
| autoscaling_min_capacity | Atlantis minimum tasks to run | string | `1` | no |
198219
| branch | Atlantis branch of the GitHub repository, _e.g._ `master` | string | `master` | no |

README.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ usage: |-
142142
143143
```
144144
module "atlantis" {
145-
source = "git::https://github.com/cloudposse/terraform-aws-ecs-atlantis.git?ref=master"
145+
source = "git::https://github.com/cloudposse/terraform-aws-ecs-atlantis.git?ref=master"
146146
enabled = "true"
147147
name = "${var.name}"
148148
namespace = "${var.namespace}"
@@ -155,7 +155,6 @@ usage: |-
155155
156156
alb_arn_suffix = "${module.alb.alb_arn_suffix}"
157157
alb_dns_name = "${module.alb.alb_dns_name}"
158-
alb_listener_arns = ["${module.alb.listener_arns}"]
159158
alb_name = "${module.alb.alb_name}"
160159
alb_zone_id = "${module.alb.alb_zone_id}"
161160
@@ -167,6 +166,12 @@ usage: |-
167166
private_subnet_ids = ["${module.subnets.private_subnet_ids}"]
168167
security_group_ids = ["${module.vpc.vpc_default_security_group_id}"]
169168
vpc_id = "${module.vpc.vpc_id}"
169+
170+
alb_ingress_unauthenticated_listener_arns = ["${module.alb.listener_arns}"]
171+
alb_ingress_unauthenticated_listener_arns_count = 2
172+
alb_ingress_unauthenticated_paths = ["/*"]
173+
alb_ingress_listener_unauthenticated_priority = "100"
174+
alb_ingress_authenticated_paths = []
170175
}
171176
```
172177

docs/terraform.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
| alb_arn_suffix | The ARN suffix of the ALB | string | - | yes |
66
| alb_dns_name | DNS name of ALB | string | - | yes |
77
| alb_ingress_authenticated_hosts | Authenticated hosts to match in Hosts header (a maximum of 1 can be defined) | list | `<list>` | no |
8+
| alb_ingress_authenticated_listener_arns | A list of authenticated ALB listener ARNs to attach ALB listener rules to | list | `<list>` | no |
9+
| alb_ingress_authenticated_listener_arns_count | The number of authenticated ARNs in `alb_ingress_authenticated_listener_arns`. This is necessary to work around a limitation in Terraform where counts cannot be computed | string | `0` | no |
810
| alb_ingress_authenticated_paths | Authenticated path pattern to match (a maximum of 1 can be defined) | list | `<list>` | no |
911
| alb_ingress_listener_authenticated_priority | The priority for the rules with authentication, between 1 and 50000 (1 being highest priority). Must be different from `alb_ingress_listener_unauthenticated_priority` since a listener can't have multiple rules with the same priority | string | `100` | no |
1012
| alb_ingress_listener_unauthenticated_priority | The priority for the rules without authentication, between 1 and 50000 (1 being highest priority). Must be different from `alb_ingress_listener_authenticated_priority` since a listener can't have multiple rules with the same priority | string | `50` | no |
1113
| alb_ingress_unauthenticated_hosts | Unauthenticated hosts to match in Hosts header (a maximum of 1 can be defined) | list | `<list>` | no |
14+
| alb_ingress_unauthenticated_listener_arns | A list of unauthenticated ALB listener ARNs to attach ALB listener rules to | list | `<list>` | no |
15+
| alb_ingress_unauthenticated_listener_arns_count | The number of unauthenticated ARNs in `alb_ingress_unauthenticated_listener_arns`. This is necessary to work around a limitation in Terraform where counts cannot be computed | string | `0` | no |
1216
| alb_ingress_unauthenticated_paths | Unauthenticated path pattern to match (a maximum of 1 can be defined) | list | `<list>` | no |
13-
| alb_listener_arns | A list of ALB listener ARNs | list | - | yes |
14-
| alb_listener_arns_count | Number of elements in the list of ALB Listener ARNs for the ECS service | string | `2` | no |
1517
| alb_name | The Name of the ALB | string | - | yes |
1618
| alb_target_group_alarms_alarm_actions | A list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an ALARM state from any other state. | list | `<list>` | no |
1719
| alb_target_group_alarms_insufficient_data_actions | A list of ARNs (i.e. SNS Topic ARN) to execute when ALB Target Group alarms transition into an INSUFFICIENT_DATA state from any other state. | list | `<list>` | no |
@@ -28,7 +30,16 @@
2830
| atlantis_wake_word | Wake world for Atlantis | string | `atlantis` | no |
2931
| atlantis_webhook_format | Template for the Atlantis webhook URL which is populated with the hostname | string | `https://%s/events` | no |
3032
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
31-
| authentication_action | Authentication action to be placed in front of all other ALB listener actions to authenticate users with Cognito or OIDC. Required when `alb_ingress_authenticated_hosts` or `alb_ingress_authenticated_paths` are provided | map | `<map>` | no |
33+
| authentication_cognito_user_pool_arn | Cognito User Pool ARN | string | `` | no |
34+
| authentication_cognito_user_pool_client_id | Cognito User Pool Client ID | string | `` | no |
35+
| authentication_cognito_user_pool_domain | Cognito User Pool Domain. The User Pool Domain should be set to the domain prefix (`xxx`) instead of full domain (https://xxx.auth.us-west-2.amazoncognito.com) | string | `` | no |
36+
| authentication_oidc_authorization_endpoint | OIDC Authorization Endpoint | string | `` | no |
37+
| authentication_oidc_client_id | OIDC Client ID | string | `` | no |
38+
| authentication_oidc_client_secret | OIDC Client Secret | string | `` | no |
39+
| authentication_oidc_issuer | OIDC Issuer | string | `` | no |
40+
| authentication_oidc_token_endpoint | OIDC Token Endpoint | string | `` | no |
41+
| authentication_oidc_user_info_endpoint | OIDC User Info Endpoint | string | `` | no |
42+
| authentication_type | Authentication type. Supported values are `COGNITO`, `OIDC`, `NONE` | string | `NONE` | no |
3243
| autoscaling_max_capacity | Atlantis maximum tasks to run | string | `1` | no |
3344
| autoscaling_min_capacity | Atlantis minimum tasks to run | string | `1` | no |
3445
| branch | Atlantis branch of the GitHub repository, _e.g._ `master` | string | `master` | no |

examples/with_cognito_authentication/main.tf

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,22 @@ module "atlantis" {
9292
security_group_ids = ["${module.vpc.vpc_default_security_group_id}"]
9393
vpc_id = "${module.vpc.vpc_id}"
9494

95-
# NOTE: Cognito and OIDC authentication only supported on HTTPS endpoints; here we provide `https_listener_arn` from ALB
96-
alb_listener_arns = ["${module.alb.https_listener_arn}"]
97-
alb_listener_arns_count = 1
95+
alb_ingress_authenticated_listener_arns = ["${module.alb.https_listener_arn}"]
96+
alb_ingress_authenticated_listener_arns_count = 1
9897

99-
# Unauthenticated paths
98+
alb_ingress_unauthenticated_listener_arns = ["${module.alb.listener_arns}"]
99+
alb_ingress_unauthenticated_listener_arns_count = 2
100+
101+
# Unauthenticated paths (with higher priority than the authenticated paths)
100102
alb_ingress_unauthenticated_paths = ["/events"]
101103
alb_ingress_listener_unauthenticated_priority = "50"
102104

103105
# Authenticated paths
104106
alb_ingress_authenticated_paths = ["/*"]
105107
alb_ingress_listener_authenticated_priority = "100"
106108

107-
# https://www.terraform.io/docs/providers/aws/r/lb_listener_rule.html
108-
authentication_action = {
109-
type = "authenticate-cognito"
110-
111-
authenticate_cognito = [{
112-
user_pool_arn = "${var.cognito_user_pool_arn}"
113-
user_pool_client_id = "${var.cognito_user_pool_client_id}"
114-
115-
# NOTE: The User Pool Domain should be set to the domain prefix (`xxx`) instead of full domain (https://xxx.auth.us-west-2.amazoncognito.com)
116-
user_pool_domain = "${var.cognito_user_pool_domain}"
117-
}]
118-
}
109+
authentication_type = "COGNITO"
110+
authentication_cognito_user_pool_arn = "${var.cognito_user_pool_arn}"
111+
authentication_cognito_user_pool_client_id = "${var.cognito_user_pool_client_id}"
112+
authentication_cognito_user_pool_domain = "${var.cognito_user_pool_domain}"
119113
}

examples/with_google_oidc_authentication/main.tf

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,32 +92,25 @@ module "atlantis" {
9292
security_group_ids = ["${module.vpc.vpc_default_security_group_id}"]
9393
vpc_id = "${module.vpc.vpc_id}"
9494

95-
# NOTE: Cognito and OIDC authentication only supported on HTTPS endpoints; here we provide `https_listener_arn` from ALB
96-
alb_listener_arns = ["${module.alb.https_listener_arn}"]
97-
alb_listener_arns_count = 1
95+
alb_ingress_authenticated_listener_arns = ["${module.alb.https_listener_arn}"]
96+
alb_ingress_authenticated_listener_arns_count = 1
9897

99-
# Unauthenticated paths
98+
alb_ingress_unauthenticated_listener_arns = ["${module.alb.listener_arns}"]
99+
alb_ingress_unauthenticated_listener_arns_count = 2
100+
101+
# Unauthenticated paths (with higher priority than the authenticated paths)
100102
alb_ingress_unauthenticated_paths = ["/events"]
101103
alb_ingress_listener_unauthenticated_priority = "50"
102104

103105
# Authenticated paths
104106
alb_ingress_authenticated_paths = ["/*"]
105107
alb_ingress_listener_authenticated_priority = "100"
106108

107-
# https://www.terraform.io/docs/providers/aws/r/lb_listener_rule.html
108-
authentication_action = {
109-
type = "authenticate-oidc"
110-
111-
authenticate_oidc = [{
112-
# Use this URL to create a Google OAuth 2.0 Client and obtain the Client ID and Client Secret: https://console.developers.google.com/apis/credentials
113-
client_id = "${var.google_oidc_client_id}"
114-
client_secret = "${var.google_oidc_client_secret}"
115-
116-
# Use this URL to get Google Auth endpoints: https://accounts.google.com/.well-known/openid-configuration
117-
issuer = "https://accounts.google.com"
118-
authorization_endpoint = "https://accounts.google.com/o/oauth2/v2/auth"
119-
token_endpoint = "https://oauth2.googleapis.com/token"
120-
user_info_endpoint = "https://openidconnect.googleapis.com/v1/userinfo"
121-
}]
122-
}
109+
authentication_type = "OIDC"
110+
authentication_oidc_client_id = "${var.google_oidc_client_id}"
111+
authentication_oidc_client_secret = "${var.google_oidc_client_secret}"
112+
authentication_oidc_issuer = "https://accounts.google.com"
113+
authentication_oidc_authorization_endpoint = "https://accounts.google.com/o/oauth2/v2/auth"
114+
authentication_oidc_token_endpoint = "https://oauth2.googleapis.com/token"
115+
authentication_oidc_user_info_endpoint = "https://openidconnect.googleapis.com/v1/userinfo"
123116
}

examples/without_authentication/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ module "atlantis" {
9292
security_group_ids = ["${module.vpc.vpc_default_security_group_id}"]
9393
vpc_id = "${module.vpc.vpc_id}"
9494

95-
alb_listener_arns = ["${module.alb.listener_arns}"]
96-
97-
# If using without authentication, we support both HTTP and HTTPS endpoints for Atlantis
98-
alb_listener_arns_count = 2
95+
# Without authentication, both HTTP and HTTPS endpoints are supported
96+
alb_ingress_unauthenticated_listener_arns = ["${module.alb.listener_arns}"]
97+
alb_ingress_unauthenticated_listener_arns_count = 2
9998

99+
# All paths are unauthenticated
100100
alb_ingress_unauthenticated_paths = ["/*"]
101-
alb_ingress_listener_unauthenticated_priority = "50"
101+
alb_ingress_listener_unauthenticated_priority = "100"
102102
alb_ingress_authenticated_paths = []
103103
}

0 commit comments

Comments
 (0)