Я могу решить мою проблему, разделив указанный выше стек на две части
1.Стек для пользовательских лямбда
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"ProjectId": {
"Type": "String",
"Description": "Name of the ProjectId."
},
"BucketName": {
"Type": "String",
"Description": "Name of the BucketName."
}
},
"Resources": {
"DeploymentLambdaRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "PermissionsToLogsAndS3",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Resource": [
"arn:aws:logs:*:*:*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"*"
]
}
]
}
}
]
}
},
"DeploymentLambda": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Role": {
"Fn::GetAtt": [
"DeploymentLambdaRole",
"Arn"
]
},
"Handler": "bucketexists.handler",
"Runtime": "nodejs4.3",
"Code": {
"S3Bucket": "xxxxxxxx",
"S3Key": "bucketcondition.zip"
}
}
},
"BucketExists": {
"Type": "Custom::BucketExists",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"DeploymentLambda",
"Arn"
]
},
"Bucket": {
"Ref": "BucketName"
}
}
}
},
"Outputs" : {
"BucketExistsValue" : {
"Description": "The Value of custom bucket lambda",
"Value" : { "Fn::GetAtt" : [ "BucketExists", "Output" ]}
}
}
}
2.Стек для корзины S3
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"BucketExistsValue": {
"Type": "String",
"Description": "Return value of the Bucket."
},
"ProjectId": {
"Type": "String",
"Description": "Name of the Project."
}
},
"Conditions" : {
"BucketExistsOutput" : {"Fn::Equals" : [{ "Ref" :"BucketExistsValue" }, "False"]}
},
"Resources": {
"S3BucketARN": {
"Type" : "AWS::S3::Bucket",
"Condition" : "BucketExistsOutput",
"Properties" : {
"BucketName" : { "Fn::Join": [
"-",
[
"testpika",
{
"Ref": "ProjectId"
},
{
"Ref": "AWS::Region"
}
]
] }
}
}
}
}
С помощью Codepipeline
я создаю два действия на этапе развертывания 1, за которыми следует 2 (т.е. 1 -> 2).В 1-ом стеке я буду хранить выходные данные пользовательской лямбды в качестве пары значений ключа в выходном артефакте, а во 2-м стеке я буду использовать выходной артефакт для передачи пользовательской пары значений лямбда-ключей в качестве входного параметра, используя Переопределение параметров ,
Спасибо