here is my template
{
"AWSTemplateFormatVersion":"2010-09-09",
"Resources":{
"lambdafunction":{
"Type":"AWS::Lambda::Function",
"Properties":{
"Handler":"index.handler",
"Role":{
"Fn::GetAtt":[
"RootRole",
"Arn"
]
},
"Code":{
"S3Bucket":"{s3_bucket_name}",
"S3Key":"lambda-zip"
},
"Runtime":"java8",
"Timeout":"25"
}
},
"RootRole":{
"Type":"AWS::IAM::Role",
"Properties":{
"AssumeRolePolicyDocument":{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":[
"ec2.amazonaws.com"
]
},
"Action":[
"sts:AssumeRole"
]
}
]
},
"Path":"/",
"Policies":[
{
"PolicyName":"root",
"PolicyDocument":{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":"*",
"Resource":"*"
}
]
}
}
]
}
}
}
}
The name of the lambda function after the stack creation is lambda-lambdafunction-18SJKJ5Q40AKZ The name of IAM role is lambda-RootRole-12S8E9CA0EOVM
The template does not seem to have a way to define the lambda function name http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html . And I am not sure why random characters are appended at the end.
Update: both AWS::IAM::Role and AWS::Lambda::Function now support custom names.
By default, CloudFormation generates a unique ID for resource names. This makes sense because it allows you to re-use the template again and again.
Some resource types, but not all, support custom names. Examples that do support custom names are AWS::DynamoDB::Table ('TableName') and AWS::S3::Bucket ('BucketName').
For more info, and a complete list of resources that support custom names, see here .
Actually, I discovered that "FunctionName" allows you to name the Lambda functions:
"LambdaResourceName": {
"Type": "AWS::Lambda::Function",
"Properties": {
"FunctionName": "",
"Description": "",
"Handler": "app.handler",
"Role":
"Code":
"Runtime": "node.js"
在Role的属性中使用“ RoleName”,在Lambda的属性中使用“ FunctionName”为Lambda函数和要创建的Role指定特定的名称。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.