--- ######################################################################################## # Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # # software and associated documentation files (the "Software"), to deal in the Software# # without restriction, including without limitation the rights to use, copy, modify, # # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # # permit persons to whom the Software is furnished to do so. # # # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ######################################################################################## AWSTemplateFormatVersion: 2010-09-09 Description: Template to create Lambda functions used for deploying vRouter Appliances Parameters: pLogsRetentionInDays: Description: 'Specifies the number of days you want to retain log events in the specified log group.' Type: Number Default: 30 AllowedValues: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653] pS3LambdaBucket: # The S3 Bucket which contains the Lambda Source Files. Description: The S3 Bucket which contains the Lambda Source Files. Type: String Resources: vRouterLambdaRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: lambda.amazonaws.com Action: - sts:AssumeRole Path: / ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole Policies: - PolicyName: EC2ReadOnly PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: - ec2:Describe* - lambda:InvokeFunction - ssm:GetParameter Resource: "*" GetIpsLambda: Type: AWS::Lambda::Function Properties: Code: S3Bucket: !Sub ${pS3LambdaBucket} S3Key: GetIps.zip Environment: Variables: logging_level: INFO Handler: index.lambda_handler MemorySize: 128 Role: !GetAtt vRouterLambdaRole.Arn Runtime: python3.9 Timeout: 120 vRouterInterfacesLambda: Type: AWS::Lambda::Function Properties: Code: S3Bucket: !Sub ${pS3LambdaBucket} S3Key: vRouterInterfaces.zip Environment: Variables: logging_level: INFO Handler: index.lambda_handler MemorySize: 128 Role: !GetAtt vRouterLambdaRole.Arn Runtime: python3.9 Timeout: 120 GetIpsLambdaLogGroup: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/${GetIpsLambda} RetentionInDays: !Ref pLogsRetentionInDays vRouterInterfaceLambdaLogGroup: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/${vRouterInterfacesLambda} RetentionInDays: !Ref pLogsRetentionInDays rStoreLambdaArn: Type: AWS::SSM::Parameter Properties: Type: String Description: ARN for Lambda that returns last 3 IPs of provided subnet Name: /automation/GetIps/lambdaArn Value: !Sub ${GetIpsLambda.Arn} rCfnMacro: Type: AWS::CloudFormation::Macro Properties: Name: vRouterInterfaces Description: This Macro will generate vRouter Interfaces for ISV subnets needing attached to a given vRouter. FunctionName: !Ref 'vRouterInterfacesLambda'