Amazon web services 有没有办法配置';堆栈名称';AWS cloudformation中嵌套堆栈的数量?

Amazon web services 有没有办法配置';堆栈名称';AWS cloudformation中嵌套堆栈的数量?,amazon-web-services,amazon-cloudformation,Amazon Web Services,Amazon Cloudformation,我正在尝试使用AWS CloudFormation创建嵌套堆栈。 我需要指定嵌套堆栈的“堆栈名称”。 我尝试使用带有键“Stack Name”的“Tags”属性。但那没用。 在创建嵌套堆栈时,有没有办法提供堆栈名称作为输入?如下文所述,目前的答案是否定的 是的,它是作为堆栈名的资源名。下面是一个名为myStackName的堆栈 亚马尔 JSON 在给定模板中,您可以访问伪参数stackId和stackName。这些可以标记为导出,然后在另一个堆栈中引用。加入后,它们将为您提供子堆栈的名称 我发现

我正在尝试使用AWS CloudFormation创建嵌套堆栈。 我需要指定嵌套堆栈的“堆栈名称”。 我尝试使用带有键“Stack Name”的“Tags”属性。但那没用。
在创建嵌套堆栈时,有没有办法提供堆栈名称作为输入?

如下文所述,目前的答案是否定的

是的,它是作为堆栈名的资源名。下面是一个名为myStackName的堆栈

亚马尔

JSON


在给定模板中,您可以访问伪参数stackId和stackName。这些可以标记为导出,然后在另一个堆栈中引用。加入后,它们将为您提供子堆栈的名称

我发现以下视频尽管年代久远,但还是非常有用:

此示例模板也有助于理解这些操作的工作原理:


我试过这样做。但是子堆栈的名称是像
ParentStackName ResourceName UniqueID
一样生成的,而不仅仅是资源名称。例如,如果父堆栈名称是我的服务,而资源名称是我的资源,则嵌套堆栈的名称类似于
我的服务我的资源IHTJ**JKT
@Neethu,我担心这就是AWS目前的工作方式,我不知道还有其他选择。很多CF资源名称都是以这种方式派生的,包括ECS集群和ALB目标,它们没有自己的名称参数。希望这会改变。所以现在的答案是“否”。为什么“需要指定嵌套堆栈的“堆栈名”?了解这一点可以帮助我们找到解决您问题的最佳方案。
AWSTemplateFormatVersion: "2010-09-09"
Resources: 
  myStackName: 
Type: "AWS::CloudFormation::Stack"
Properties: 
  TemplateURL: "https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2ChooseAMI.template"
  Parameters: 
    InstanceType: "t1.micro"
    KeyName: "mykey"
{
"AWSTemplateFormatVersion" : "2010-09-09",
   "Resources" : {
  "myStackName" : {
     "Type" : "AWS::CloudFormation::Stack",
     "Properties" : {
        "TemplateURL" : "https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2ChooseAMI.template",
        "Parameters" : {
           "InstanceType" : "t1.micro",
           "KeyName" : "mykey"
        }
     }
  }
}
}
{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation Sample Template VPC_with_PublicIPs_And_DNS: Sample template that creates a VPC with DNS and public IPs enabled. Note that you are billed for the AWS resources that you use when you create a stack from this template.", "Resources" : { "VPC" : { "Type" : "AWS::EC2::VPC", "Properties" : { "EnableDnsSupport" : "true", "EnableDnsHostnames" : "true", "CidrBlock" : "10.0.0.0/16" } }, "PublicSubnet" : { "Type" : "AWS::EC2::Subnet", "Properties" : { "VpcId" : { "Ref" : "VPC" }, "CidrBlock" : "10.0.0.0/24" } }, "InternetGateway" : { "Type" : "AWS::EC2::InternetGateway" }, "VPCGatewayAttachment" : { "Type" : "AWS::EC2::VPCGatewayAttachment", "Properties" : { "VpcId" : { "Ref" : "VPC" }, "InternetGatewayId" : { "Ref" : "InternetGateway" } } }, "PublicRouteTable" : { "Type" : "AWS::EC2::RouteTable", "Properties" : { "VpcId" : { "Ref" : "VPC" } } }, "PublicRoute" : { "Type" : "AWS::EC2::Route", "DependsOn" : "VPCGatewayAttachment", "Properties" : { "RouteTableId" : { "Ref" : "PublicRouteTable" }, "DestinationCidrBlock" : "0.0.0.0/0", "GatewayId" : { "Ref" : "InternetGateway" } } }, "PublicSubnetRouteTableAssociation" : { "Type" : "AWS::EC2::SubnetRouteTableAssociation", "Properties" : { "SubnetId" : { "Ref" : "PublicSubnet" }, "RouteTableId" : { "Ref" : "PublicRouteTable" } } }, "PublicSubnetNetworkAclAssociation" : { "Type" : "AWS::EC2::SubnetNetworkAclAssociation", "Properties" : { "SubnetId" : { "Ref" : "PublicSubnet" }, "NetworkAclId" : { "Fn::GetAtt" : ["VPC", "DefaultNetworkAcl"] } } }, "WebServerSecurityGroup" : { "Type" : "AWS::EC2::SecurityGroup", "Properties" : { "GroupDescription" : "Enable HTTP ingress", "VpcId" : { "Ref" : "VPC" }, "SecurityGroupIngress" : [ { "IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0" } ] } } }, "Outputs" : { "VPCId" : { "Description" : "VPC ID", "Value" : { "Ref" : "VPC" }, "Export" : { "Name" : {"Fn::Sub": "${AWS::StackName}-VPCID" }} }, "PublicSubnet" : { "Description" : "The subnet ID to use for public web servers", "Value" : { "Ref" : "PublicSubnet" }, "Export" : { "Name" : {"Fn::Sub": "${AWS::StackName}-SubnetID" }} }, "WebServerSecurityGroup" : { "Description" : "The security group ID to use for public web servers", "Value" : { "Fn::GetAtt" : ["WebServerSecurityGroup", "GroupId"] }, "Export" : { "Name" : {"Fn::Sub": "${AWS::StackName}-SecurityGroupID" }} } } }