首页 > 解决方案 > 部署“未找到”堆栈时,某些给定参数未解析

问题描述

我想创建和部署一个模板,该模板本身会部署 AWS 服务目录中的产品。这是我的模板:

Parameters:
  ProductId:
    Type: String
  ProvisioningArtifactName:
    Type: String
  Description:
    Type: String
  Region:
    Type: CommaDelimitedList
  VpcSize:
    Type: String
  BastionHostKeyName:
    Type: String
  ProvisioningArtifactName:
    Type: String
Resources:
  VPCAndMore:
    Type: AWS::ServiceCatalog::CloudFormationProvisionedProduct
    Properties:
      ProductId: ProductId
      ProvisioningArtifactName: ProvisioningArtifactName
      ProvisioningParameters:
        - Key: Description
          Value: Description
        - Key: AvailabilityZones
          Value: Region
        - Key: VpcSize
          Value: VpcSize
        - Key: BastionHostKeyName
          Value: BastionHostKeyName

当我尝试手动部署它时,我输入了所有参数值。它们绝对是正确的,并且来自正确的类型。但是一旦我部署它,我就会收到这样的错误:

Product ProductId not found. (Service: ServiceCatalog, Status Code: 400, Request ID: 35f27a2a-1317-48d0-815e-16ebe949d039, Extended Request ID: null)

由于某种原因,ProductId参数似乎没有解析。

我错过了什么?还是 CF 不支持参数解析ProvisioningParameters

标签: amazon-web-servicesamazon-cloudformation

解决方案


对于内部函数 Ref需要引用如下定义的值:

Parameters:
  ProductId:
    Type: String
  ProvisioningArtifactName:
    Type: String
  Description:
    Type: String
  Region:
    Type: CommaDelimitedList
  VpcSize:
    Type: String
  BastionHostKeyName:
    Type: String
  ProvisioningArtifactName:
    Type: String
Resources:
  VPCAndMore:
    Type: AWS::ServiceCatalog::CloudFormationProvisionedProduct
    Properties:
      ProductId: !Ref ProductId
      ProvisioningArtifactName: !Ref ProvisioningArtifactName
      ProvisioningParameters:
        - Key: Description
          Value: !Ref Description
        - Key: AvailabilityZones
          Value: !Ref Region
        - Key: VpcSize
          Value: !Ref VpcSize
        - Key: BastionHostKeyName
          Value: !Ref BastionHostKeyName

推荐阅读