Skip to content

Commit c26c44e

Browse files
authored
fix: Fixed incorrect example of iam-eks-role (#183)
1 parent 7bb7652 commit c26c44e

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

examples/iam-eks-role/README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,29 @@ Run `terraform destroy` when you don't need these resources.
2121
|------|---------|
2222
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.6 |
2323
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.23 |
24+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2 |
2425

2526
## Providers
2627

27-
No providers.
28+
| Name | Version |
29+
|------|---------|
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.23 |
31+
| <a name="provider_random"></a> [random](#provider\_random) | >= 2 |
2832

2933
## Modules
3034

3135
| Name | Source | Version |
3236
|------|--------|---------|
37+
| <a name="module_eks"></a> [eks](#module\_eks) | terraform-aws-modules/eks/aws | ~> 18.0 |
3338
| <a name="module_iam_eks_role"></a> [iam\_eks\_role](#module\_iam\_eks\_role) | ../../modules/iam-eks-role | n/a |
3439

3540
## Resources
3641

37-
No resources.
42+
| Name | Type |
43+
|------|------|
44+
| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
45+
| [aws_subnet_ids.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source |
46+
| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
3847

3948
## Inputs
4049

examples/iam-eks-role/main.tf

+31-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ module "iam_eks_role" {
77
role_name = "my-app"
88

99
cluster_service_accounts = {
10-
"cluster1" = ["default:my-app"]
11-
"cluster2" = [
12-
"default:my-app",
13-
"canary:my-app",
14-
]
10+
(random_pet.this.id) = ["default:my-app", "canary:my-app"]
1511
}
1612

1713
provider_url_sa_pairs = {
@@ -30,3 +26,33 @@ module "iam_eks_role" {
3026
"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
3127
]
3228
}
29+
30+
##################
31+
# Extra resources
32+
##################
33+
34+
resource "random_pet" "this" {
35+
length = 2
36+
}
37+
38+
module "eks" {
39+
source = "terraform-aws-modules/eks/aws"
40+
version = "~> 18.0"
41+
42+
cluster_name = random_pet.this.id
43+
cluster_version = "1.21"
44+
45+
vpc_id = data.aws_vpc.default.id
46+
subnet_ids = data.aws_subnet_ids.all.ids
47+
}
48+
49+
##################################################################
50+
# Data sources to get VPC, subnet, security group and AMI details
51+
##################################################################
52+
data "aws_vpc" "default" {
53+
default = true
54+
}
55+
56+
data "aws_subnet_ids" "all" {
57+
vpc_id = data.aws_vpc.default.id
58+
}

examples/iam-eks-role/versions.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ terraform {
22
required_version = ">= 0.12.6"
33

44
required_providers {
5-
aws = ">= 2.23"
5+
aws = ">= 2.23"
6+
random = ">= 2"
67
}
78
}

0 commit comments

Comments
 (0)