Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Support capabilities during stack updates
Browse files Browse the repository at this point in the history
ADD: Support for capabilities in update() that is consistent with create()
REMOVE: Unused 'cfn_capabilities' variable in create()
  • Loading branch information
emoffett committed Aug 4, 2023
1 parent 20dd5a4 commit ff71e8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ def create(event, context):
Create a cfn stack using an assumed role
"""

cfn_capabilities = []
if 'capabilities' in event['ResourceProperties'].keys():
cfn_capabilities = event['ResourceProperties']['Capabilities']
cfn_client = boto3.client("cloudformation")
params = get_cfn_parameters(event)
prefix = event['ResourceProperties']['ParentStackId'].split("/")[1]
Expand Down Expand Up @@ -347,17 +344,21 @@ def update(event, context):
Update a cfn stack using an assumed role
"""
stack_id = event["PhysicalResourceId"]
cfn_capabilities = []
capabilities = []
if 'capabilities' in event['ResourceProperties'].keys():
cfn_capabilities = event['ResourceProperties']['capabilities']
capabilities = event['ResourceProperties']['capabilities']
cfn_client = get_client("cloudformation", event, context)
physical_resource_id = stack_id
prefix = event['ResourceProperties']['ParentStackId'].split("/")[1]
parent_properties = cfn_client.describe_stacks(StackName=prefix)['Stacks'][0]
if 'Capabilities' in parent_properties.keys():
capabilities = parent_properties['Capabilities']
try:
cfn_client.update_stack(
StackName=stack_id,
TemplateURL=event['ResourceProperties']['TemplateURL'],
Parameters=get_cfn_parameters(event),
Capabilities=cfn_capabilities,
Capabilities=capabilities,
Tags=[{
'Key': 'ParentStackId',
'Value': event['ResourceProperties']['ParentStackId']
Expand Down

0 comments on commit ff71e8f

Please sign in to comment.