Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SAM Function and SAM StateMachines to Propagate Tags to Generated Resources #3200

Merged
merged 6 commits into from
Jun 2, 2023

Conversation

GavinZZ
Copy link
Contributor

@GavinZZ GavinZZ commented Jun 2, 2023

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.

  • When ApiId is provided in the API event source, customers have to manually define a API resource. We would not consider this API resource as a generated resource.
  • When ApiId is not provided, then SAM-T generates an implicit API for customers and this implicit API should be considered as a generated resource and hence propagate tags.
    (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 API ServerlessRestApi 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 documentation

  1. api_with_propagate_tags covers all generated api resources, including AWS::ApiGateway::RestApi, AWS::ApiGateway::Stage, AWS::ApiGateway::Deployment, AWS::ApiGateway::DomainName, AWS::ApiGateway::UsagePlan, AWS::ApiGateway::UsagePlanKey, AWS::ApiGateway::ApiKey.
  2. httpapi_with_propagate_tags (in previous PR) covers all generated http api resources, including AWS::ApiGatewayV2::Api, AWS::ApiGatewayV2::Stage, AWS::ApiGatewayV2::DomainName.
  3. function_with_events_and_propagate_tags covers all generated resources that can have tags, including AWS::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.
  4. state_machine_with_api_and_propagate_tags covers all resources that can have tags AWS::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.

@GavinZZ GavinZZ requested a review from a team as a code owner June 2, 2023 18:55
.cfnlintrc.yaml Show resolved Hide resolved
@GavinZZ GavinZZ merged commit 6a58236 into aws:develop Jun 2, 2023
8 checks passed
@GavinZZ GavinZZ deleted the propagate_tags2 branch June 2, 2023 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants