AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: Canary Deployment ################################################################################################### ## Template Parameters ## ################################################################################################### Parameters: AppName: Type: String Description: Name of application (no spaces). Value must be globally unique Default: canary-deployment ################################################################################################### ## Template Resources ## ################################################################################################### Resources: ## API Gateway SiteAPI: Type: AWS::Serverless::Api Properties: StageName: Prod EndpointConfiguration: REGIONAL CanarySetting: PercentTraffic: 100 TracingEnabled: true MethodSettings: - HttpMethod: "*" ResourcePath: "/*" LoggingLevel: INFO DataTraceEnabled: true MetricsEnabled: true - HttpMethod: "GET" ResourcePath: "/{year}" DefinitionBody: "Fn::Transform": Name: "AWS::Include" Parameters: Location: "./api.yaml" ## URL DynamoDB Table DataTable: Type: AWS::DynamoDB::Table Properties: KeySchema: - AttributeName: year KeyType: HASH AttributeDefinitions: - AttributeName: year AttributeType: S BillingMode: PAY_PER_REQUEST ################################################################################################### ## IAM Roles ## ################################################################################################### CloudWatchRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - apigateway.amazonaws.com Action: 'sts:AssumeRole' Path: / ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs ## Dynamo DB Read Role DDBReadRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: "apigateway.amazonaws.com" Action: - "sts:AssumeRole" Policies: - PolicyName: DDBReadPolicy PolicyDocument: Version: "2012-10-17" Statement: Action: - dynamodb:GetItem Effect: Allow Resource: !GetAtt DataTable.Arn ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs ################################################################################################### ## Metrics outputs ## ################################################################################################### Outputs: AppName: Description: Name Value: !Ref AppName