Skip to content

Commit 57dde28

Browse files
committed
Allowed the user to specify role ARNs instead of the template creating them.
1 parent 3147105 commit 57dde28

File tree

1 file changed

+51
-21
lines changed

1 file changed

+51
-21
lines changed

Monitoring/CloudWatch-FSx/cloudformation-template.json

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"SecurityGroupIds",
1515
"CreateFsxServiceEndpoint",
1616
"CreateSecretManagerEndpoint",
17-
"CreateCloudWatchEndpoint"
17+
"CreateCloudWatchEndpoint",
18+
"LambdaRoleArn",
19+
"SchedulerRoleArn"
1820
]
1921
},
2022
{
@@ -67,6 +69,12 @@
6769
"SnsTopicArn": {
6870
"default": "SNS Topic ARN for CloudWatch alarms - Optional"
6971
},
72+
"LambdaRoleArn": {
73+
"default": "Lambda Role ARN if you don't want this CloudFormation template to create one - Optional"
74+
},
75+
"SchedulerRoleArn": {
76+
"default": "Scheduler Role ARN if you don't want this CloudFormation template to create one - Optional"
77+
},
7078
"SendUsage": {
7179
"default": "Agree to Send Usage Data"
7280
}
@@ -115,6 +123,16 @@
115123
"Default": "false",
116124
"Description": "A boolean flag indicating whether you plan to create a CloudWatch VPC endpoint inside the VPC. Set this to true if you want to create the endpoint, or false if you don't. The decision to create this endpoint depends on whether you already have this type of endpoint. If you already have one, set this to false; otherwise, set it to true."
117125
},
126+
"LambdaRoleArn": {
127+
"Type": "String",
128+
"Description": "The ARN of the IAM role that will be associated with the Lambda function when it runs.",
129+
"Default": ""
130+
},
131+
"SchedulerRoleArn": {
132+
"Type": "String",
133+
"Description": "The ARN of the IAM role that will be associated with the Schedulers when they run.",
134+
"Default": ""
135+
},
118136
"SendUsage": {
119137
"Type": "String",
120138
"AllowedValues": ["true", "false"],
@@ -159,6 +177,22 @@
159177
}
160178
]
161179
},
180+
"NeedToCreateSchedulerRole": {
181+
"Fn::Equals": [
182+
{
183+
"Ref": "SchedulerRoleArn"
184+
},
185+
""
186+
]
187+
},
188+
"NeedToCreateLambdaRole": {
189+
"Fn::Equals": [
190+
{
191+
"Ref": "LambdaRoleArn"
192+
},
193+
""
194+
]
195+
},
162196
"NeedToSendUsage": {
163197
"Fn::Equals": [
164198
{
@@ -242,6 +276,7 @@
242276
},
243277
"LambdaRole": {
244278
"Type": "AWS::IAM::Role",
279+
"Condition": "NeedToCreateLambdaRole",
245280
"Properties": {
246281
"RoleName": {
247282
"Fn::Sub": [
@@ -344,12 +379,10 @@
344379
]
345380
}
346381
},
347-
"Role": {
348-
"Fn::GetAtt": [
349-
"LambdaRole",
350-
"Arn"
351-
]
352-
},
382+
"Role": {"Fn::If": ["NeedToCreateLambdaRole",
383+
{"Fn::GetAtt": [ "LambdaRole", "Arn" ]},
384+
{"Ref": "LambdaRoleArn"}
385+
]},
353386
"VpcConfig": {
354387
"SecurityGroupIds": {
355388
"Ref": "SecurityGroupIds"
@@ -378,6 +411,7 @@
378411
},
379412
"SchedulerRole": {
380413
"Type": "AWS::IAM::Role",
414+
"Condition": "NeedToCreateSchedulerRole",
381415
"Properties": {
382416
"RoleName": {
383417
"Fn::Sub": [
@@ -418,7 +452,7 @@
418452
}
419453
}]
420454
}
421-
},
455+
},
422456
"MetricsScheduler": {
423457
"Type": "AWS::Scheduler::Schedule",
424458
"Properties": {
@@ -434,12 +468,10 @@
434468
"Arn"
435469
]
436470
},
437-
"RoleArn": {
438-
"Fn::GetAtt": [
439-
"SchedulerRole",
440-
"Arn"
441-
]
442-
},
471+
"RoleArn": {"Fn::If": ["NeedToCreateSchedulerRole",
472+
{"Fn::GetAtt": [ "SchedulerRole", "Arn" ]},
473+
{"Ref": "SchedulerRoleArn"}
474+
]},
443475
"Input": {
444476
"Fn::ToJsonString": {
445477
"action": "putMetricsCommand",
@@ -467,12 +499,10 @@
467499
"Arn"
468500
]
469501
},
470-
"RoleArn": {
471-
"Fn::GetAtt": [
472-
"SchedulerRole",
473-
"Arn"
474-
]
475-
},
502+
"RoleArn": {"Fn::If": ["NeedToCreateSchedulerRole",
503+
{"Fn::GetAtt": [ "SchedulerRole", "Arn" ]},
504+
{"Ref": "SchedulerRoleArn"}
505+
]},
476506
"Input": {
477507
"Fn::ToJsonString": {
478508
"action": "manageAlarmsCommand",
@@ -1436,4 +1466,4 @@
14361466
}
14371467
}
14381468
}
1439-
}
1469+
}

0 commit comments

Comments
 (0)