aws-cloudformation / aws-cloudformation-resource-providers-codeartifact

The CloudFormation Resource Provider Package for the AWS CodeArtifact service
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_CodeArtifact.html
Apache License 2.0
27 stars 7 forks source link

Adding isCreated to callback context to allow for retries #57

Closed jonjara closed 3 years ago

jonjara commented 3 years ago

Issue #, if available:

Description of changes:

Setting isCreated flag when domain is created so that if the handler retries for any reason, we don't get a 409. The flag state gets preserved if the handler set it and it gets called again.

Testing Ran lambda locally with a context delay to force a retry and the retry succeeded without a 409.

[CREATE] invoking handler...
Domain was already created, will not call CreateDomain again.
AWS::CodeArtifact::Domain read handler is being invoked
AWS::CodeArtifact::Domain describeDomain is being invoked
{"apiRequest": {"requestId": "1f39dc8d-c2c2-4313-ba69-b1e3a770d574", "requestName": "DescribeDomainRequest"}}
AWS::CodeArtifact::Domain has successfully been read.
AWS::CodeArtifact::Domain getDomainPolicy is being invoked
Failed to execute remote function: {No policy found for (domain): (domain-retried) (Service: Codeartifact, Status Code: 404, Request ID: a69ecfec-53c2-4faa-bbd9-adf419b985c9, Extended Request ID: null)}
Domain policy of AWS::CodeArtifact::Domain has successfully been read.
[CREATE] handler invoked
Handler returned SUCCESS

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.