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

Update examples/template.yml #403

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 49 additions & 45 deletions examples/template.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,84 @@
# https://github.com/awslabs/aws-cloudformation-templates/blob/master/community/services/Lambda/LambdaSample.yaml
AWSTemplateFormatVersion: '2010-09-09'
# https://github.com/aws-cloudformation/aws-cloudformation-templates/blob/main/Lambda/LambdaSample.yaml
AWSTemplateFormatVersion: "2010-09-09"

Description: Template for Lambda Sample.

Parameters:
EnvName:
Type: String
Description: Name of an environment. 'dev', 'staging', 'prod' and any name.
Type: String
AllowedPattern: ^.*[^0-9]$
ConstraintDescription: Must end with non-numeric character.

LambdaHandlerPath:
Type: String
Description: Path of a Lambda Handler.
Type: String
AllowedPattern: ^.*[^0-9]$
ConstraintDescription: Must end with non-numeric character.
Outputs:
LambdaRoleARN:
Description: Role for Lambda execution.
Value:
Fn::GetAtt:
- LambdaRole
- Arn
Export:
Name:
Fn::Sub: LambdaRole-${EnvName}
LambdaFunctionName:
Value:
Ref: LambdaFunction
LambdaFunctionARN:
Description: Lambda function ARN.
Value:
Fn::GetAtt:
- LambdaFunction
- Arn
Export:
Name:
Fn::Sub: LambdaARN-${EnvName}

Resources:
LambdaRole:
Type: AWS::IAM::Role
Properties:
RoleName:
Fn::Sub: lambda-role-${EnvName}
RoleName: lambda-role
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Version: 2012-10-17
- lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSLambdaExecute
- arn:aws:iam::aws:policy/AmazonS3FullAccess
- arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess
- arn:aws:iam::aws:policy/AmazonKinesisFullAccess
Path: /

LambdaFunction:
Type: AWS::Lambda::Function
Metadata:
guard:
SuppressedRules:
- LAMBDA_INSIDE_VPC
- LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED
Properties:
FunctionName:
Fn::Sub: lambda-function-${EnvName}
Description: LambdaFunctioni of nodejs18.x.
Runtime: nodejs18.x
FunctionName: !Sub lambda-function-${EnvName}
Description: LambdaFunction using python3.12.
Runtime: python3.12

Check failure on line 50 in examples/template.yml

View workflow job for this annotation

GitHub Actions / ubuntu-20.04

E3030 You must specify a valid value for Runtime (python3.12). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7"]

Check failure on line 50 in examples/template.yml

View workflow job for this annotation

GitHub Actions / ubuntu-22.04

E3030 You must specify a valid value for Runtime (python3.12). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7"]

Check failure on line 50 in examples/template.yml

View workflow job for this annotation

GitHub Actions / windows-2019

E3030 You must specify a valid value for Runtime (python3.12). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7"]

Check failure on line 50 in examples/template.yml

View workflow job for this annotation

GitHub Actions / windows-2022

E3030 You must specify a valid value for Runtime (python3.12). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7"]

Check failure on line 50 in examples/template.yml

View workflow job for this annotation

GitHub Actions / macos-13

E3030 You must specify a valid value for Runtime (python3.12). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7"]

Check failure on line 50 in examples/template.yml

View workflow job for this annotation

GitHub Actions / macos-14

E3030 You must specify a valid value for Runtime (python3.12). Valid values are ["dotnet6", "dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java11", "java8", "java8.al2", "nodejs", "nodejs10.x", "nodejs12.x", "nodejs14.x", "nodejs16.x", "nodejs18.x", "nodejs4.3", "nodejs4.3-edge", "nodejs6.10", "nodejs8.10", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "python3.9", "ruby2.5", "ruby2.7"]
ScottBrenner marked this conversation as resolved.
Show resolved Hide resolved
Code:
ZipFile:
"exports.handler = function(event, context){\n
var sample = sample;"
Handler: !Ref LambdaHandlerPath
ZipFile: |
import json

def lambda_handler(event, context):
print(json.dumps(event))
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Handler: !Sub ${LambdaHandlerPath}
MemorySize: 128
Timeout: 10
Role:
Fn::GetAtt:
- LambdaRole
- Arn
Role: !GetAtt LambdaRole.Arn
Environment:
Variables:
ENV:
Fn::Sub: ${EnvName}
ENV: !Ref EnvName
TZ: UTC

Outputs:
LambdaRoleARN:
Description: Role for Lambda execution.
Value: !GetAtt LambdaRole.Arn
Export:
Name: LambdaRole

LambdaFunctionName:
Value: !Ref LambdaFunction

LambdaFunctionARN:
Description: Lambda function ARN.
Value: !GetAtt LambdaFunction.Arn
Export:
Name: !Sub LambdaARN-${EnvName}
Loading