|
3 | 3 | ## Features
|
4 | 4 |
|
5 | 5 | 1. **Cross-account access.** Define IAM roles using `iam_assumable_role` or `iam_assumable_roles` submodules in "resource AWS accounts (prod, staging, dev)" and IAM groups and users using `iam-group-with-assumable-roles-policy` submodule in "IAM AWS Account" to setup access controls between accounts. See [iam-group-with-assumable-roles-policy example](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-with-assumable-roles-policy) for more details.
|
6 |
| -1. **Individual IAM resources (users, roles, policies).** See usage snippets and [examples](https://github.com/terraform-aws-modules/terraform-aws-iam#examples) listed below. |
| 6 | +2. **Individual IAM resources (users, roles, policies).** See usage snippets and [examples](https://github.com/terraform-aws-modules/terraform-aws-iam#examples) listed below. |
7 | 7 |
|
8 | 8 | ## Usage
|
9 | 9 |
|
@@ -134,63 +134,31 @@ module "iam_assumable_roles_with_saml" {
|
134 | 134 | }
|
135 | 135 | ```
|
136 | 136 |
|
137 |
| -`iam-user`: |
| 137 | +`iam-eks-role`: |
138 | 138 |
|
139 | 139 | ```hcl
|
140 |
| -module "iam_user" { |
141 |
| - source = "terraform-aws-modules/iam/aws//modules/iam-user" |
142 |
| - version = "~> 4" |
143 |
| -
|
144 |
| - name = "vasya.pupkin" |
145 |
| - force_destroy = true |
146 |
| -
|
147 |
| - pgp_key = "keybase:test" |
148 |
| -
|
149 |
| - password_reset_required = false |
150 |
| -} |
151 |
| -``` |
| 140 | +module "iam_eks_role" { |
| 141 | + source = "terraform-aws-modules/iam/aws//modules/iam-eks-role" |
| 142 | + version = "~> 4" |
152 | 143 |
|
153 |
| -`iam-policy`: |
| 144 | + role_name = "my-app" |
154 | 145 |
|
155 |
| -```hcl |
156 |
| -module "iam_policy" { |
157 |
| - source = "terraform-aws-modules/iam/aws//modules/iam-policy" |
158 |
| - version = "~> 4" |
| 146 | + cluster_service_accounts = { |
| 147 | + "cluster1" = ["default:my-app"] |
| 148 | + "cluster2" = [ |
| 149 | + "default:my-app", |
| 150 | + "canary:my-app", |
| 151 | + ] |
| 152 | + } |
159 | 153 |
|
160 |
| - name = "example" |
161 |
| - path = "/" |
162 |
| - description = "My example policy" |
| 154 | + tags = { |
| 155 | + Name = "eks-role" |
| 156 | + } |
163 | 157 |
|
164 |
| - policy = <<EOF |
165 |
| -{ |
166 |
| - "Version": "2012-10-17", |
167 |
| - "Statement": [ |
168 |
| - { |
169 |
| - "Action": [ |
170 |
| - "ec2:Describe*" |
171 |
| - ], |
172 |
| - "Effect": "Allow", |
173 |
| - "Resource": "*" |
174 |
| - } |
| 158 | + role_policy_arns = [ |
| 159 | + "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", |
175 | 160 | ]
|
176 | 161 | }
|
177 |
| -EOF |
178 |
| -} |
179 |
| -``` |
180 |
| - |
181 |
| -`iam-read-only-policy`: |
182 |
| - |
183 |
| -```hcl |
184 |
| -module "iam_read_only_policy" { |
185 |
| - source = "terraform-aws-modules/iam/aws//modules/iam-read-only-policy" |
186 |
| - version = "~> 4" |
187 |
| -
|
188 |
| - name = "example" |
189 |
| - path = "/" |
190 |
| - description = "My example read-only policy" |
191 |
| -
|
192 |
| - allowed_services = ["rds", "dynamo", "health"] |
193 |
| -} |
194 | 162 | ```
|
195 | 163 |
|
196 | 164 | `iam-group-with-assumable-roles-policy`:
|
@@ -242,30 +210,87 @@ module "iam_group_with_policies" {
|
242 | 210 | }
|
243 | 211 | ```
|
244 | 212 |
|
245 |
| -`iam-eks-role`: |
| 213 | +`iam-policy`: |
246 | 214 |
|
247 | 215 | ```hcl
|
248 |
| -module "iam_eks_role" { |
249 |
| - source = "terraform-aws-modules/iam/aws//modules/iam-eks-role" |
| 216 | +module "iam_policy" { |
| 217 | + source = "terraform-aws-modules/iam/aws//modules/iam-policy" |
| 218 | + version = "~> 4" |
| 219 | +
|
| 220 | + name = "example" |
| 221 | + path = "/" |
| 222 | + description = "My example policy" |
| 223 | +
|
| 224 | + policy = <<EOF |
| 225 | +{ |
| 226 | + "Version": "2012-10-17", |
| 227 | + "Statement": [ |
| 228 | + { |
| 229 | + "Action": [ |
| 230 | + "ec2:Describe*" |
| 231 | + ], |
| 232 | + "Effect": "Allow", |
| 233 | + "Resource": "*" |
| 234 | + } |
| 235 | + ] |
| 236 | +} |
| 237 | +EOF |
| 238 | +} |
| 239 | +``` |
| 240 | + |
| 241 | +`iam-read-only-policy`: |
| 242 | + |
| 243 | +```hcl |
| 244 | +module "iam_read_only_policy" { |
| 245 | + source = "terraform-aws-modules/iam/aws//modules/iam-read-only-policy" |
| 246 | + version = "~> 4" |
| 247 | +
|
| 248 | + name = "example" |
| 249 | + path = "/" |
| 250 | + description = "My example read-only policy" |
| 251 | +
|
| 252 | + allowed_services = ["rds", "dynamo", "health"] |
| 253 | +} |
| 254 | +``` |
| 255 | + |
| 256 | +`iam-role-for-service-accounts-eks`: |
| 257 | + |
| 258 | +```hcl |
| 259 | +module "vpc_cni_irsa" { |
| 260 | + source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" |
250 | 261 | version = "~> 4"
|
251 | 262 |
|
252 |
| - role_name = "my-app" |
| 263 | + role_name = "vpc-cni" |
253 | 264 |
|
254 |
| - cluster_service_accounts = { |
255 |
| - "cluster1" = ["default:my-app"] |
256 |
| - "cluster2" = [ |
257 |
| - "default:my-app", |
258 |
| - "canary:my-app", |
259 |
| - ] |
| 265 | + attach_vpc_cni_policy = true |
| 266 | + vpc_cni_enable_ipv4 = true |
| 267 | +
|
| 268 | + oidc_providers = { |
| 269 | + main = { |
| 270 | + provider_arn = "arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D" |
| 271 | + namespace_service_accounts = ["default:my-app", "canary:my-app"] |
| 272 | + } |
260 | 273 | }
|
261 | 274 |
|
262 | 275 | tags = {
|
263 |
| - Name = "eks-role" |
| 276 | + Name = "vpc-cni-irsa" |
264 | 277 | }
|
| 278 | +} |
| 279 | +``` |
265 | 280 |
|
266 |
| - role_policy_arns = [ |
267 |
| - "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", |
268 |
| - ] |
| 281 | +`iam-user`: |
| 282 | + |
| 283 | +```hcl |
| 284 | +module "iam_user" { |
| 285 | + source = "terraform-aws-modules/iam/aws//modules/iam-user" |
| 286 | + version = "~> 4" |
| 287 | +
|
| 288 | + name = "vasya.pupkin" |
| 289 | + force_destroy = true |
| 290 | +
|
| 291 | + pgp_key = "keybase:test" |
| 292 | +
|
| 293 | + password_reset_required = false |
269 | 294 | }
|
270 | 295 | ```
|
271 | 296 |
|
@@ -318,12 +343,13 @@ Use [iam-read-only-policy module](https://github.com/terraform-aws-modules/terra
|
318 | 343 | - [iam-assumable-roles](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-roles) - Create several IAM roles which can be assumed from specified ARNs (AWS accounts, IAM users, etc)
|
319 | 344 | - [iam-assumable-roles-with-saml](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-roles-with-saml) - Create several IAM roles which can be assumed by users with a SAML Identity Provider
|
320 | 345 | - [iam-eks-role](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-eks-role) - Create an IAM role which can be assumed by one or more EKS `ServiceAccount`
|
| 346 | +- [iam-group-complete](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-complete) - IAM group with users who are allowed to assume IAM roles in another AWS account and have access to specified IAM policies |
321 | 347 | - [iam-group-with-assumable-roles-policy](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-with-assumable-roles-policy) - IAM group with users who are allowed to assume IAM roles in the same or in separate AWS account
|
322 | 348 | - [iam-group-with-policies](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-with-policies) - IAM group with users who are allowed specified IAM policies (eg, "manage their own IAM user")
|
323 |
| -- [iam-group-complete](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-complete) - IAM group with users who are allowed to assume IAM roles in another AWS account and have access to specified IAM policies |
324 |
| -- [iam-user](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-user) - Add IAM user, login profile and access keys (with PGP enabled or disabled) |
325 | 349 | - [iam-policy](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-policy) - Create IAM policy
|
326 | 350 | - [iam-read-only-policy](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-read-only-policy) - Create IAM read-only policy
|
| 351 | +- [iam-role-for-service-accounts-eks](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-role-for-service-accounts-eks) - Create IAM role for service accounts (IRSA) for use within EKS clusters |
| 352 | +- [iam-user](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-user) - Add IAM user, login profile and access keys (with PGP enabled or disabled) |
327 | 353 |
|
328 | 354 | ## Authors
|
329 | 355 |
|
|
0 commit comments