Last active
August 24, 2017 08:56
-
-
Save bsamuel-ui/cff4632e5894625bb5361646c57d1c4b to your computer and use it in GitHub Desktop.
Test if cloudformation can create stacks with CW log groups with the same name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template = ''' | |
Resources: | |
LambdaLogGroup1234: | |
Type: "AWS::Logs::LogGroup" | |
Properties: | |
LogGroupName: !Join [ "", [ "/aws/lambda/", !Ref "AWS::StackName", "1234" ] ] | |
LambdaLogGroup: | |
Type: "AWS::Logs::LogGroup" | |
Properties: | |
LogGroupName: !Join [ "", [ "/aws/lambda/", !Ref "AWS::StackName" ] ] | |
DependsOn: "LambdaLogGroup1234" | |
Outputs: | |
NeedsThatName: | |
Value: !GetAtt LambdaLogGroup.Arn | |
''' | |
import boto3, os | |
cf = boto3.client('cloudformation') | |
stack_name = 'test-log-issue-' + str(os.getpid()) | |
cf.create_stack(StackName=stack_name, TemplateBody=template, OnFailure='ROLLBACK') | |
try: | |
cf.get_waiter('stack_create_complete').wait(StackName=stack_name) | |
except Exception: | |
print("No love. :-(") | |
else: | |
print("Hooray, they fixed it!!!") | |
finally: | |
cf.delete_stack(StackName=stack_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment