Skip to content

Commit 673fb44

Browse files
authored
fix: Use the aws_service_principal data source to retrieve the correct service principal for IRSA policies (#628)
1 parent f336f09 commit 673fb44

File tree

14 files changed

+99
-56
lines changed

14 files changed

+99
-56
lines changed

examples/iam-account/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Configuration in this directory sets [AWS account alias](https://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html) (also known as Console Account alias) and configures password policy.
44

5-
# Usage
5+
## Usage
66

77
To run this example you need to execute:
88

99
```bash
10-
$ terraform init
11-
$ terraform plan
12-
$ terraform apply
10+
terraform init
11+
terraform plan
12+
terraform apply
1313
```
1414

1515
Run `terraform destroy` when you don't need these resources.

examples/iam-group/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Configuration in this directory creates IAM group with users who are allowed to assume IAM roles and extended with IAM policies.
44

5-
# Usage
5+
## Usage
66

77
To run this example you need to execute:
88

99
```bash
10-
$ terraform init
11-
$ terraform plan
12-
$ terraform apply
10+
terraform init
11+
terraform plan
12+
terraform apply
1313
```
1414

1515
Run `terraform destroy` when you don't need these resources.

examples/iam-oidc-provider/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
- Creates an IAM identity provider for GitHub OIDC
44
- Creates an IAM role that trust the IAM GitHub OIDC provider
5-
- GitHub reference: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
6-
- AWS IAM role reference: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html#idp_oidc_Create_GitHub
5+
- [GitHub reference](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
6+
- [AWS IAM role reference](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html#idp_oidc_Create_GitHub)
77

88
Note: an IAM provider is 1 per account per given URL. This module would be provisioned once per AWS account, and multiple roles created with this provider as the trusted identity (typically 1 role per GitHub repository).
99

10+
## Usage
11+
1012
To run this example you need to execute:
1113

1214
```bash
13-
$ terraform init
14-
$ terraform plan
15-
$ terraform apply
15+
terraform init
16+
terraform plan
17+
terraform apply
1618
```
1719

1820
Run `terraform destroy` when you don't need these resources.

examples/iam-policy/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Configuration in this directory creates IAM policies.
44

5-
# Usage
5+
## Usage
66

77
To run this example you need to execute:
88

99
```bash
10-
$ terraform init
11-
$ terraform plan
12-
$ terraform apply
10+
terraform init
11+
terraform plan
12+
terraform apply
1313
```
1414

1515
Run `terraform destroy` when you don't need these resources.

examples/iam-read-only-policy/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Configuration in this directory creates a read-only IAM policy and attaches it to an AWS SSO permission set.
44

5-
# Usage
5+
## Usage
66

77
To run this example you need to execute:
88

99
```bash
10-
$ terraform init
11-
$ terraform plan
12-
$ terraform apply
10+
terraform init
11+
terraform plan
12+
terraform apply
1313
```
1414

1515
Run `terraform destroy` when you don't need these resources.

examples/iam-role-for-service-accounts/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
77
Configuration in this directory creates IAM roles that can be assumed by multiple EKS `ServiceAccount`s for various tasks.
88

9-
# Usage
9+
## Usage
1010

1111
To run this example you need to execute:
1212

1313
```bash
14-
$ terraform init
15-
$ terraform plan
16-
$ terraform apply
14+
terraform init
15+
terraform plan
16+
terraform apply
1717
```
1818

1919
Run `terraform destroy` when you don't need these resources.

examples/iam-role/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Configuration in this directory creates IAM roles with different options for permissions and role assumption.
44

5-
# Usage
5+
## Usage
66

77
To run this example you need to execute:
88

99
```bash
10-
$ terraform init
11-
$ terraform plan
12-
$ terraform apply
10+
terraform init
11+
terraform plan
12+
terraform apply
1313
```
1414

1515
Run `terraform destroy` when you don't need these resources.

examples/iam-user/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
Configuration in this directory creates an IAM user with a random password, a pair of IAM access/secret keys, uploads IAM SSH public key, and demonstrates inline policy creation.
44
User password and secret key is encrypted using public key of keybase.io user named `test`.
55

6-
# Usage
6+
## Usage
77

88
To run this example you need to execute:
99

1010
```bash
11-
$ terraform init
12-
$ terraform plan
13-
$ terraform apply
11+
terraform init
12+
terraform plan
13+
terraform apply
1414
```
1515

1616
Run `terraform destroy` when you don't need these resources.

modules/iam-role-for-service-accounts/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
> The [karpenter](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/modules/karpenter) sub-module contains the necessary AWS resources for running Karpenter, including the Karpenter controller IAM role & policy
99
1010
Creates an IAM role which can be assumed by AWS EKS `ServiceAccount`s with optional policies for commonly used controllers/custom resources within EKS. The optional policies supported include:
11+
1112
- [Cert-Manager](https://cert-manager.io/docs/configuration/acme/dns01/route53/#set-up-an-iam-role)
1213
- [Cluster Autoscaler](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md)
1314
- [EBS CSI Driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/example-iam-policy.json)
@@ -158,6 +159,10 @@ No modules.
158159
| [aws_iam_policy_document.velero](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
159160
| [aws_iam_policy_document.vpc_cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
160161
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
162+
| [aws_service_principal.delivery_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/service_principal) | data source |
163+
| [aws_service_principal.elasticloadbalancing](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/service_principal) | data source |
164+
| [aws_service_principal.fsx](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/service_principal) | data source |
165+
| [aws_service_principal.vpc_lattice](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/service_principal) | data source |
161166

162167
## Inputs
163168

@@ -213,6 +218,7 @@ No modules.
213218
| <a name="input_policy_description"></a> [policy\_description](#input\_policy\_description) | IAM policy description | `string` | `null` | no |
214219
| <a name="input_policy_name"></a> [policy\_name](#input\_policy\_name) | Name to use on IAM policy created | `string` | `null` | no |
215220
| <a name="input_policy_path"></a> [policy\_path](#input\_policy\_path) | Path of IAM policy | `string` | `null` | no |
221+
| <a name="input_region"></a> [region](#input\_region) | Region where *select resource(s) will be managed (IAM resources are global). Defaults to the Region set in the provider configuration | `string` | `null` | no |
216222
| <a name="input_source_inline_policy_documents"></a> [source\_inline\_policy\_documents](#input\_source\_inline\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. Statements must have unique `sid`s | `list(string)` | `[]` | no |
217223
| <a name="input_source_policy_documents"></a> [source\_policy\_documents](#input\_source\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. Statements must have unique `sid`s | `list(string)` | `[]` | no |
218224
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |

modules/iam-role-for-service-accounts/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
data "aws_partition" "current" {
2-
count = var.create ? 1 : 0
3-
}
4-
51
locals {
6-
partition = try(data.aws_partition.current[0].partition, "")
7-
dns_suffix = try(data.aws_partition.current[0].dns_suffix, "")
8-
92
policy_description = try(coalesce(
103
var.policy_description,
114
var.attach_aws_gateway_controller_policy ? "Provides permissions for the AWS Gateway Controller" : null,

0 commit comments

Comments
 (0)