Created
February 28, 2022 14:45
-
-
Save ShubhamKhairnar/22f4f95cf3b228e3a2583c5453c34415 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: > | |
Template for deploying lambda function | |
Parameters: | |
LambdaSg: | |
Description: "Lambda security group ID" | |
Type: AWS::EC2::SecurityGroup::Id | |
LambdaSubnets: | |
Description: "Lambda subnets" | |
Type: List<AWS::EC2::Subnet::Id> | |
LambdaEnv: | |
Description: "Environment" | |
Type: String | |
Resources: | |
<FUNCTION_NAME>: | |
Type: AWS::Serverless::Function | |
Properties: | |
Description: <FUNCTION_DESCRIPTION> | |
CodeUri: . | |
Environment: | |
Variables: | |
ENV: !Ref LambdaEnv | |
FunctionName: <FUNCTION_NAME> | |
Handler: index.<FUNCTION_NAME> | |
MemorySize: 128 | |
Runtime: nodejs14.x | |
Timeout: 15 | |
VpcConfig: | |
SecurityGroupIds: | |
- !Ref LambdaSg | |
SubnetIds: !Ref LambdaSubnets | |
Policies: | |
- VPCAccessPolicy: {} | |
Role: !GetAtt <FUNCTION_ROLE_NAME>.Arn | |
<FUNCTION_ROLE_NAME>: | |
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: <FUNCTION_POLICY_NAME> | |
PolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Action: | |
- "ec2:DescribeNetworkInterfaces" | |
- "ec2:CreateNetworkInterface" | |
- "ec2:DeleteNetworkInterface" | |
- "ec2:DescribeInstances" | |
- "ec2:AttachNetworkInterface" | |
Resource: "*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment