Allow SAM Function and SAM StateMachines to Propagate Tags to Generated Resources #3200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available
Description of changes
In the previous PR, we have supported
PropagateTags
in SAM API and SAM HttpApi. This PR targets to support SAM Function and SAM StateMachine.Note that SAM Function and SAM StateMachine support API as an event source.
(I have covered this edge case in the state_machine_with_api_and_propagate_tags test where we have two state machine with api event source. One defining
ApiId
and a custom API resource; the other don't. The expected result is tags should be propagate to the implicit APIServerlessRestApi
while the custom defined one doesn't have tags)Description of how you validated changes
We have complete set of unit tests covering changes. There is transform tests covering each
PropagateTags
supported SAM resource and make sure the generated resource's tags are expected. The generated resources matches our documentationapi_with_propagate_tags
covers all generated api resources, includingAWS::ApiGateway::RestApi
,AWS::ApiGateway::Stage
,AWS::ApiGateway::Deployment
,AWS::ApiGateway::DomainName
,AWS::ApiGateway::UsagePlan
,AWS::ApiGateway::UsagePlanKey
,AWS::ApiGateway::ApiKey
.httpapi_with_propagate_tags
(in previous PR) covers all generated http api resources, includingAWS::ApiGatewayV2::Api
,AWS::ApiGatewayV2::Stage
,AWS::ApiGatewayV2::DomainName
.function_with_events_and_propagate_tags
covers all generated resources that can have tags, includingAWS::Lambda::Function
,AWS::Lambda::Alias
,AWS::Lambda::Version
,AWS::IAM::Role
,AWS::CodeDeploy::Application
,AWS::CodeDeploy::DeploymentGroup
,AWS::ApiGateway::RestApi
,AWS::ApiGatewayV2::Api
,AWS::Lambda::EventSourceMapping
,AWS::Events::Rule
,AWS::IoT::TopicRule
,AWS::Lambda::EventInvokeConfig
,AWS::SNS::Topic
,AWS::SQS::Queue
.state_machine_with_api_and_propagate_tags
covers all resources that can have tagsAWS::StepFunctions::StateMachine
,AWS::IAM::Role
,AWS::ApiGateway::RestApi
.Verified that SAM will propagate the tags defined to the ones with
Tags
property.Checklist
Examples?
Please reach out in the comments if you want to add an example. Examples will be
added to
sam init
through aws/aws-sam-cli-app-templates.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.