File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,14 +82,14 @@ module "example" {
8282| Name | Description | Type | Default | Required |
8383| ------| -------------| ------| ---------| :--------:|
8484| entity | The name of the entity (usually a GitHub repository) being tested (e.g. molecule-iam-user-tf-module). | ` string ` | n/a | yes |
85- | ssm\_ parameters | The AWS SSM parameters that the IAM user needs to be able to read (e.g. [ "/example/parameter1", "/example/config/* "] ). | ` list(string) ` | n/a | yes |
85+ | ssm\_ parameters | The AWS SSM parameters that the IAM user needs to be able to read (e.g. [ "/example/parameter1", "/example/config/* "] ). | ` list(string) ` | ` [] ` | no |
8686
8787## Outputs ##
8888
8989| Name | Description |
9090| ------| -------------|
9191| access\_ key | The IAM access key associated with the CI IAM user created by this module. |
92- | role | The IAM role that the CI user can assume to read SSM parameters . |
92+ | role | The IAM role that the CI user can assume to perform testing . |
9393| user | The CI IAM user created by this module. |
9494<!-- END_TF_DOCS -->
9595
Original file line number Diff line number Diff line change 11# IAM policy document that allows assumption of the ParameterStoreReadOnly
22# role in the Images account for this user
33data "aws_iam_policy_document" "assume_parameterstorereadonly_role_doc" {
4+ count = local. ssm_needed
5+
46 statement {
57 actions = [
68 " sts:AssumeRole" ,
79 " sts:TagSession" ,
810 ]
911 effect = " Allow"
1012 resources = [
11- module . parameterstorereadonly_role . role . arn
13+ module . parameterstorereadonly_role [ 0 ] . role . arn
1214 ]
1315 }
1416}
1517
1618# The IAM policy allowing this user to assume their custom
1719# ParameterStoreReadOnly role in the Images account
1820resource "aws_iam_user_policy" "assume_parameterstorereadonly" {
19- name = " Images-Assume${ module . parameterstorereadonly_role . role . name } "
20- policy = data. aws_iam_policy_document . assume_parameterstorereadonly_role_doc . json
21+ count = local. ssm_needed
22+
23+ name = " Images-Assume${ module . parameterstorereadonly_role [0 ]. role . name } "
24+ policy = data. aws_iam_policy_document . assume_parameterstorereadonly_role_doc [0 ]. json
2125 user = module. ci_user . user . name
2226}
Original file line number Diff line number Diff line change 11locals {
2- user_name = format (" test-%s" , var. entity )
3- role_name = format (" Test-%s" , var. entity )
42 role_description = format (" A role that can be assumed to allow for CI testing of %s via Molecule." , var. entity )
3+ role_name = format (" Test-%s" , var. entity )
4+
5+ # Determine if the CI user needs to be able to read SSM parameters
6+ ssm_needed = length (var. ssm_parameters ) > 0 ? 1 : 0
7+
8+ user_name = format (" test-%s" , var. entity )
59}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ output "access_key" {
55}
66
77output "role" {
8- description = " The IAM role that the CI user can assume to read SSM parameters ."
8+ description = " The IAM role that the CI user can assume to perform testing ."
99 value = module. ci_user . role
1010}
1111
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ data "aws_caller_identity" "users" {
99}
1010
1111module "parameterstorereadonly_role" {
12+ count = local. ssm_needed
1213 source = " github.com/cisagov/ssm-read-role-tf-module"
1314
1415 providers = {
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ module "ci_user" {
1313
1414# Attach the AWS SSM Parameter Store read role policy to the CI role
1515resource "aws_iam_role_policy_attachment" "ssm" {
16+ count = local. ssm_needed
1617 provider = aws. images-provisionaccount
1718
18- policy_arn = module. parameterstorereadonly_role . policy . arn
19+ policy_arn = module. parameterstorereadonly_role [ 0 ] . policy . arn
1920 role = module. ci_user . role . name
2021}
Original file line number Diff line number Diff line change @@ -10,14 +10,15 @@ variable "entity" {
1010 type = string
1111}
1212
13- variable "ssm_parameters" {
14- description = " The AWS SSM parameters that the IAM user needs to be able to read (e.g. [\" /example/parameter1\" , \" /example/config/*\" ])."
15- nullable = false
16- type = list (string )
17- }
18-
1913# ------------------------------------------------------------------------------
2014# OPTIONAL PARAMETERS
2115#
2216# These parameters have reasonable defaults.
2317# ------------------------------------------------------------------------------
18+
19+ variable "ssm_parameters" {
20+ default = []
21+ description = " The AWS SSM parameters that the IAM user needs to be able to read (e.g. [\" /example/parameter1\" , \" /example/config/*\" ])."
22+ nullable = false
23+ type = list (string )
24+ }
You can’t perform that action at this time.
0 commit comments