Skip to content

Commit 8943b5c

Browse files
committed
Refactor runbook to remove AWS resource providers ID mappings and load from external JSON file
1 parent f10b70c commit 8943b5c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

codebundles/aws-c7n-tag-compliance/runbook.robot

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ Suite Initialization
8989
... pattern=^[a-zA-Z0-9,]+$
9090
... example=ec2,rds,vpc,iam-group,iam-policy,iam-user,security-group
9191
... default=ec2,rds,vpc,iam-group,iam-policy,iam-user,security-group
92-
${AWS_RESOURCE_PROVIDERS_ID_MAPPINGS}= RW.Core.Import User Variable AWS_RESOURCE_PROVIDERS_ID_MAPPINGS
93-
... type=string
94-
... description=Comma-separated list of AWS Resource Providers and the corresponding ID field name.
95-
... pattern=^[a-zA-Z0-9,]+$
96-
... example=ec2=InstanceId,rds=DBInstanceIdentifier
97-
... default=ec2=InstanceId,rds=DBInstanceIdentifier,vpc=VpcId,iam-group=GroupId,iam-policy=PolicyId,iam-user=UserId,security-group=GroupId
9892
${AWS_TAGS}= RW.Core.Import User Variable AWS_TAGS
9993
... type=string
10094
... description=Comma-separated list of mandatory tags that AWS resources must have for compliance. These tags will be checked across all specified resource types.
@@ -114,7 +108,6 @@ Suite Initialization
114108
Set Suite Variable ${AWS_ACCOUNT_ID} ${AWS_ACCOUNT_ID}
115109
Set Suite Variable ${AWS_ACCESS_KEY_ID} ${AWS_ACCESS_KEY_ID}
116110
Set Suite Variable ${AWS_SECRET_ACCESS_KEY} ${AWS_SECRET_ACCESS_KEY}
117-
Set Suite Variable ${AWS_RESOURCE_PROVIDERS_ID_MAPPINGS} ${AWS_RESOURCE_PROVIDERS_ID_MAPPINGS}
118111

119112
Process Resources
120113
[Arguments] ${region} ${c7n_output}
@@ -161,9 +154,10 @@ Process Resources
161154
${missing_tags}= Evaluate ", ".join($cleaned_tags)
162155
# Load resource ID mappings from external JSON file
163156
TRY
164-
${resource_id_mapping}= GENERATE RESOURCE ID MAPPINGS ${AWS_RESOURCE_PROVIDERS_ID_MAPPINGS}
157+
${resource_id_mappings_json}= RW.CLI.Run Cli cmd=cat ${CURDIR}/resource_id_mappings.json
158+
${resource_id_mapping}= Evaluate json.loads(r'''${resource_id_mappings_json.stdout}''') json
165159
EXCEPT
166-
Log Failed to load resource ID mappings file, using default mapping WARN
160+
Log Failed to load resource_id_mappings.json, using default mapping WARN
167161
${resource_id_mapping}= Create Dictionary
168162
END
169163

0 commit comments

Comments
 (0)