Skip to content

Commit 72fe3a7

Browse files
author
Eduardo Lopez
authored
[feature] Allow the aws-iam-role-crossacct for OIDC federation (#179)
[feature] Allow the aws-iam-role-crossacct for OIDC federation### Summary Augments the aws-iam-role-crossacct for OIDC federation ### Test Plan test in internal repo ### References
1 parent 968da0b commit 72fe3a7

File tree

7 files changed

+40
-4
lines changed

7 files changed

+40
-4
lines changed

aws-aurora-mysql/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ No provider.
4141
|------|-------------|------|---------|:-----:|
4242
| apply\_immediately | If false changes will not be applied until next maintenance window. | `string` | `false` | no |
4343
| backtrack\_window | Turns on Backgrack for this many seconds. [Doc](https://aws.amazon.com/blogs/aws/amazon-aurora-backtrack-turn-back-time/) | `string` | `0` | no |
44-
| ca\_cert\_identifier | Identifier for the certificate authority. 9 is the latest available version. | `string` | `"rds-ca-2015"` | no |
44+
| ca\_cert\_identifier | Identifier for the certificate authority. 9 is the latest available version. | `string` | `"rds-ca-2019"` | no |
4545
| database\_name | The name of the database to be created in the cluster. | `string` | n/a | yes |
4646
| database\_password | Password for user that will be created. | `string` | n/a | yes |
4747
| database\_subnet\_group | The name of an existing database subnet group to use. | `string` | n/a | yes |

aws-aurora-postgres/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ No provider.
3939
| Name | Description | Type | Default | Required |
4040
|------|-------------|------|---------|:-----:|
4141
| apply\_immediately | If false changes will not be applied until next maintenance window. | `string` | `false` | no |
42-
| ca\_cert\_identifier | Identifier for the certificate authority. Use rds-ca-2015 for anything new. | `string` | `"rds-ca-2015"` | no |
42+
| ca\_cert\_identifier | Identifier for the certificate authority. | `string` | `"rds-ca-2019"` | no |
4343
| database\_name | The name of the database to be created in the cluster. | `string` | n/a | yes |
4444
| database\_password | Password for user that will be created. | `string` | n/a | yes |
4545
| database\_subnet\_group | The name of an existing database subnet group to use. | `string` | n/a | yes |

aws-aurora/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is a low-level module for creating AWS Aurora clusters. We strongly reccome
1515
|------|-------------|------|---------|:-----:|
1616
| apply\_immediately | n/a | `bool` | `false` | no |
1717
| backtrack\_window | n/a | `number` | `0` | no |
18-
| ca\_cert\_identifier | Identifier for the certificate authority. Use rds-ca-2015 for anything new. | `string` | `"rds-ca-2015"` | no |
18+
| ca\_cert\_identifier | Identifier for the certificate authority. Use rds-ca-2015 for anything new. | `string` | `"rds-ca-2019"` | no |
1919
| database\_name | n/a | `string` | n/a | yes |
2020
| database\_password | n/a | `string` | n/a | yes |
2121
| database\_subnet\_group | n/a | `string` | n/a | yes |
@@ -33,6 +33,7 @@ This is a low-level module for creating AWS Aurora clusters. We strongly reccome
3333
| instance\_count | n/a | `string` | `1` | no |
3434
| kms\_key\_id | If supplied, RDS will use this key to encrypt data at rest. Empty string means that RDS will use an AWS-managed key. Encryption is always on with this module. | `string` | `""` | no |
3535
| owner | Owner for tagging and naming. See [doc](../README.md#consistent-tagging). | `string` | n/a | yes |
36+
| params\_engine\_version | n/a | `string` | n/a | yes |
3637
| performance\_insights\_enabled | n/a | `string` | `true` | no |
3738
| port | n/a | `string` | n/a | yes |
3839
| project | Project for tagging and naming. See [doc](../README.md#consistent-tagging) | `string` | n/a | yes |

aws-iam-role-crossacct/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module "group" {
2828
| Name | Description | Type | Default | Required |
2929
|------|-------------|------|---------|:-----:|
3030
| iam\_path | The IAM path to put this role in. | `string` | `"/"` | no |
31+
| oidc | A list of AWS OIDC IDPs to establish a trust relationship for this role. | <pre>list(object(<br> {<br> idp_arn : string, # the AWS IAM IDP arn<br> client_ids : list(string), # a list of oidc client ids<br> provider : string # your provider url, such as foo.okta.com<br> }<br> ))<br></pre> | `[]` | no |
3132
| role\_name | The name of the role. | `string` | n/a | yes |
3233
| saml\_idp\_arn | The AWS SAML IDP arn to establish a trust relationship. Ignored if empty or not provided. | `string` | `""` | no |
3334
| source\_account\_id | The source AWS account to establish a trust relationship. Ignored if empty or not provided. | `string` | `""` | no |
@@ -37,6 +38,7 @@ module "group" {
3738
| Name | Description |
3839
|------|-------------|
3940
| iam\_path | n/a |
41+
| role\_arn | n/a |
4042
| role\_name | n/a |
4143

4244
<!-- END -->

aws-iam-role-crossacct/main.tf

+20
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ data "aws_iam_policy_document" "assume-role" {
2727
}
2828
}
2929
}
30+
31+
dynamic "statement" {
32+
for_each = var.oidc
33+
iterator = oidc
34+
35+
content {
36+
principals {
37+
type = "Federated"
38+
identifiers = [oidc.value["idp_arn"]]
39+
}
40+
41+
actions = ["sts:AssumeRoleWithWebIdentity"]
42+
condition {
43+
test = "StringEquals"
44+
variable = "${oidc.value["provider"]}:aud"
45+
values = oidc.value["client_ids"]
46+
}
47+
}
48+
}
49+
3050
}
3151

3252
resource "aws_iam_role" "role" {

aws-iam-role-crossacct/variables.tf

+13
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ variable "saml_idp_arn" {
1919
default = ""
2020
description = "The AWS SAML IDP arn to establish a trust relationship. Ignored if empty or not provided."
2121
}
22+
23+
variable oidc {
24+
type = list(object(
25+
{
26+
idp_arn : string, # the AWS IAM IDP arn
27+
client_ids : list(string), # a list of oidc client ids
28+
provider : string # your provider url, such as foo.okta.com
29+
}
30+
))
31+
32+
default = []
33+
description = "A list of AWS OIDC IDPs to establish a trust relationship for this role."
34+
}

aws-s3-private-bucket/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| bucket\_policy | n/a | `string` | `""` | no |
1515
| enable\_versioning | Keep old versions of overwritten S3 objects. | `bool` | `true` | no |
1616
| env | n/a | `string` | n/a | yes |
17-
| lifecycle\_rules | List of maps containing configuration of object lifecycle management. | `any` | <pre>[<br> {<br> "enabled": true,<br> "expiration": {<br> "expired_object_delete_marker": true<br> },<br> "noncurrent_version_expiration": {<br> "days": 365<br> },<br> "noncurrent_version_transition": {<br> "days": 30,<br> "storage_class": "STANDARD_IA"<br> }<br> }<br>]</pre> | no |
17+
| lifecycle\_rules | List of maps containing configuration of object lifecycle management. | `list` | <pre>[<br> {<br> "enabled": true,<br> "expiration": {<br> "expired_object_delete_marker": true<br> },<br> "noncurrent_version_expiration": {<br> "days": 365<br> },<br> "noncurrent_version_transition": {<br> "days": 30,<br> "storage_class": "STANDARD_IA"<br> }<br> }<br>]<br></pre> | no |
1818
| owner | n/a | `string` | n/a | yes |
1919
| project | n/a | `string` | n/a | yes |
2020
| service | n/a | `string` | n/a | yes |

0 commit comments

Comments
 (0)