📜  AWS CloudFormation:假设您有一个根堆栈和一个嵌套堆栈.如何将值从根堆栈传递给嵌套堆栈?用一个例子来解释. - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:26.240000             🧑  作者: Mango

代码示例1
There is no way (yet) to pass every parameter at once from the root stack to the nested stack. If you want to pass every parameter, you have to do it one by one.

Here is sample template to give you an idea.

Master.yaml:

Resources:
  Cloudspan:
    Type: "AWS::CloudFormation::Stack"
    Properties:
      Parameters:
        LambdaName: Cloudspan
        BucketName: 
        S3KeyName: 
        FunctionName: 
      TemplateURL: 
  Alignment:
    Type: "AWS::CloudFormation::Stack"
    Properties:
      Parameters:
        LambdaName: Alignment
        BucketName: 
        S3KeyName: 
        FunctionName: 
      TemplateURL: 
Lambda-child.yaml:

Parameters:
  LambdaName:
    Type: String
  BucketName:
    Type: String
  S3KeyName:
    Type: String
  FunctionName:
    Type: String

Resources:
  LambdaFunction:
    Type: "AWS::Lambda::Function"
    Properties:
      Handler: !Sub '${LambdaName}-{FunctionName}.Handler'
      Role:
        Fn::GetAtt: ['LambdaExecutionRole', Arn ]
      Code:
        S3Bucket: !Sub '${LambdaName}{BucketName}'
        S3Key: !Sub '${LambdaName}{S3KeyName}'
      Runtime: "python3.6"