‘VPCId2’ 在堆栈中未找到。

huangapple go评论52阅读模式
英文:

Output 'VPCId2' not found in stack

问题

I created an AWS CloudFormation template that calls nested stacks to create an Application Load Balancer, EC2 instance with enable SSM and tomcat ec2 and 3 VPCs.

However, when I upload the root stack I got this error:

Output 'VPCId2' not found in stack 'arn:aws:cloudformation:us-east-1:465521475937:stack/root-VPCStack-146FM0ZNW6Y5S/60d8eaf0-dd0f-11ed-a4d3-12bfe4263bc1' for ALB

This is my root stack:

AWSTemplateFormatVersion: 2010-09-09

Description: Root template 2

Parameters:

  KeyName:
    Type: String
    Default: demo
  
  ManagementVPCBlock: 
    Type: String
    Default: "10.0.0.0/24"

  ManagementPublicSubnet01Block:
    Type: String
    Default: "10.0.0.0/28" 

  APPVPCBlock:
    Type: String
    Default: "10.0.1.0/24"

  APPPrivateSubnet02Block:
    Type: String
    Default: "10.0.1.0/28"

  APPPublicSubnet03Block:
    Type: String
    Default: "10.0.1.16/28"

  DBVPCBlock:
    Type: String
    Default: "10.0.2.0/24"

  DBPrivateSubnet04Block:
    Type: String
    Default: 10.0.2.0/28  

  APPPublicSubnet05Block:
    Type: String
    Default: "10.0.1.32/28"

  AccepterRegion:
    Description: enter the region 
    Type: String

  AccepterAccountID: 
    Description: enter the accountId 
    Type: String

Resources:

  VPCStack: 
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/VPC.yaml
      Parameters:
        ManagementVPCBlock: !Ref ManagementVPCBlock
        ManagementPublicSubnet01Block: !Ref ManagementPublicSubnet01Block
        APPVPCBlock: !Ref APPVPCBlock
        APPPrivateSubnet02Block: !Ref APPPrivateSubnet02Block
        APPPublicSubnet03Block: !Ref APPPublicSubnet03Block
        DBVPCBlock: !Ref DBVPCBlock
        DBPrivateSubnet04Block: !Ref DBPrivateSubnet04Block
        AccepterRegion: !Ref AccepterRegion
        AccepterAccountID: !Ref AccepterAccountID

      TimeoutInMinutes: 5

  ALBStack: 
    Type: AWS::CloudFormation::Stack 
    Properties:
      TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/ALB.yaml
      Parameters:
        VPCId: !GetAtt VPCStack.Outputs.VPCId2
        PublicSubnet1Id: !GetAtt VPCStack.Outputs.PublicSubnet1Id
        PublicSubnet2Id: !GetAtt VPCStack.Outputs.PublicSubnet2Id  
      TimeoutInMinutes: 5

  SSMStack:
    Type: AWS::CloudFormation::Stack 
    Properties:
      TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/SSM.yaml
      Parameters:
        VPCId: !GetAtt VPCStack.Outputs.VPCId1
        PublicSubnetId: !GetAtt VPCStack.Outputs.PublicSubnetId
      TimeoutInMinutes: 5

  TomcatEC2Stack:
    Type: AWS::CloudFormation::Stack 
    Properties:
      TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/TomcatEC2.yaml
      Parameters:
        VPCId: !GetAtt VPCStack.Outputs.VPCId2
        PrivateSubnetId: !GetAtt VPCStack.Outputs.PrivateSubnetId1
        KeyName: !Ref KeyName
      TimeoutInMinutes: 5

Outputs:
  StackRef:
    Value: !Ref VPCStack
  outputfromNestedStack:
    Value: !GetAtt VPCStack.Outputs.VPCId1
    Value: !GetAtt VPCStack.Outputs.PublicSubnetId
    Value: !GetAtt VPCStack.Outputs.VPCId2
    Value: !GetAtt VPCStack.Outputs.PrivateSubnetId1
    Value: !GetAtt VPCStack.Outputs.PublicSubnet1Id
    Value: !GetAtt VPCStack.Outputs.PublicSubnet2Id
    Value: !GetAtt VPCStack.Outputs.VPCId3
    Value: !GetAtt VPCStack.Outputs.PrivateSubnetId2

I'm stuck here. Please help.

英文:

I created an AWS CloudFormation template that calls nested stacks to create an Application Load Balancer, EC2 instance with enable SSM and tomcat ec2 and 3 VPCs.

However, when I upload the root stack I got this error:

>Output 'VPCId2' not found in stack 'arn:aws:cloudformation:us-east-1:465521475937:stack/root-VPCStack-146FM0ZNW6Y5S/60d8eaf0-dd0f-11ed-a4d3-12bfe4263bc1' for ALB

This is my root stack:

AWSTemplateFormatVersion: 2010-09-09
Description: Root template 2
Parameters:
KeyName:
Type: String
Default: demo
ManagementVPCBlock: 
Type: String
Default: "10.0.0.0/24"
ManagementPublicSubnet01Block:
Type: String
Default: "10.0.0.0/28" 
APPVPCBlock:
Type: String
Default: "10.0.1.0/24"
APPPrivateSubnet02Block:
Type: String
Default: "10.0.1.0/28"
APPPublicSubnet03Block:
Type: String
Default: "10.0.1.16/28"
DBVPCBlock:
Type: String
Default: "10.0.2.0/24"
DBPrivateSubnet04Block:
Type: String
Default: 10.0.2.0/28  
APPPublicSubnet05Block:
Type: String
Default: "10.0.1.32/28"
AccepterRegion:
Description: enter the region 
Type: String
AccepterAccountID: 
Description: enter the accountId 
Type: String
Resources:
VPCStack: 
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/VPC.yaml
Parameters:
ManagementVPCBlock: !Ref ManagementVPCBlock
ManagementPublicSubnet01Block: !Ref ManagementPublicSubnet01Block
APPVPCBlock: !Ref APPVPCBlock
APPPrivateSubnet02Block: !Ref APPPrivateSubnet02Block
APPPublicSubnet03Block: !Ref APPPublicSubnet03Block
DBVPCBlock: !Ref DBVPCBlock
DBPrivateSubnet04Block: !Ref DBPrivateSubnet04Block
AccepterRegion: !Ref AccepterRegion
AccepterAccountID: !Ref AccepterAccountID
TimeoutInMinutes: 5
ALBStack: 
Type: AWS::CloudFormation::Stack 
Properties:
TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/ALB.yaml
Parameters:
VPCId: !GetAtt VPCStack.Outputs.VPCId2
PublicSubnet1Id: !GetAtt VPCStack.Outputs.PublicSubnet1Id
PublicSubnet2Id: !GetAtt VPCStack.Outputs.PublicSubnet2Id  
TimeoutInMinutes: 5
SSMStack:
Type: AWS::CloudFormation::Stack 
Properties:
TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/SSM.yaml
Parameters:
VPCId: !GetAtt VPCStack.Outputs.VPCId1
PublicSubnetId: !GetAtt VPCStack.Outputs.PublicSubnetId
TimeoutInMinutes: 5
TomcatEC2Stack:
Type: AWS::CloudFormation::Stack 
Properties:
TemplateURL: https://stackbucket-s3bucket-1esv04po5wsk9.s3.amazonaws.com/NestedStack/TomcatEC2.yaml
Parameters:
VPCId: !GetAtt VPCStack.Outputs.VPCId2
PrivateSubnetId: !GetAtt VPCStack.Outputs.PrivateSubnetId1
KeyName: !Ref KeyName
TimeoutInMinutes: 5
Outputs:
StackRef:
Value: !Ref VPCStack
outputfromNestedStack:
Value: !GetAtt VPCStack.Outputs.VPCId1
Value: !GetAtt VPCStack.Outputs.PublicSubnetId
Value: !GetAtt VPCStack.Outputs.VPCId2
Value: !GetAtt VPCStack.Outputs.PrivateSubnetId1
Value: !GetAtt VPCStack.Outputs.PublicSubnet1Id
Value: !GetAtt VPCStack.Outputs.PublicSubnet2Id
Value: !GetAtt VPCStack.Outputs.VPCId3
Value: !GetAtt VPCStack.Outputs.PrivateSubnetId2

I'm stuck here. Please help.

答案1

得分: 2

Your VPCStack outputs appear to be as follows:

 Outputs:
VPCId:
Value: !Ref ManagementVPC
PublicSubnetId:
Value: !Ref ManagementPublicSubnet
VPCId:
Value: !Ref APPVPC
PrivateSubnetId:
Value: !Ref PrivateSubnet
PublicSubnet1Id:
Value: !Ref PublicSubnet1
PublicSubnet2Id:
Value: !Ref PublicSubnet2
VPCId:
Value: !Ref DBVPC
PrivateSubnetId:
Value: !Ref PrivateSubnet

您的VPCStack输出似乎如下:

 输出:
VPCId:
值: !Ref ManagementVPC
PublicSubnetId:
值: !Ref ManagementPublicSubnet
VPCId:
值: !Ref APPVPC
PrivateSubnetId:
值: !Ref PrivateSubnet
PublicSubnet1Id:
值: !Ref PublicSubnet1
PublicSubnet2Id:
值: !Ref PublicSubnet2
VPCId:
值: !Ref DBVPC
PrivateSubnetId:
值: !Ref PrivateSubnet

您将所有3个VPC ID输出都使用了相同的名称VPCId,但它们需要不同,例如:

 输出:
VPCId1:
值: !Ref ManagementVPC
PublicSubnetId:
值: !Ref ManagementPublicSubnet
VPCId2:
值: !Ref APPVPC
PrivateSubnetId:
值: !Ref PrivateSubnet
PublicSubnet1Id:
值: !Ref PublicSubnet1
PublicSubnet2Id:
值: !Ref PublicSubnet2
VPCId3:
值: !Ref DBVPC
PrivateSubnetId:
值: !Ref PrivateSubnet
英文:

Your VPCStack outputs appear to be as follows:

 Outputs:
VPCId:
Value: !Ref ManagementVPC
PublicSubnetId:
Value: !Ref ManagementPublicSubnet
VPCId:
Value: !Ref APPVPC
PrivateSubnetId:
Value: !Ref PrivateSubnet
PublicSubnet1Id:
Value: !Ref PublicSubnet1
PublicSubnet2Id:
Value: !Ref PublicSubnet2
VPCId:
Value: !Ref DBVPC
PrivateSubnetId:
Value: !Ref PrivateSubnet

You are outputting all 3 VPC IDs with the same name VPCId but they need to be different e.g.

 Outputs:
VPCId1:
Value: !Ref ManagementVPC
PublicSubnetId:
Value: !Ref ManagementPublicSubnet
VPCId2:
Value: !Ref APPVPC
PrivateSubnetId:
Value: !Ref PrivateSubnet
PublicSubnet1Id:
Value: !Ref PublicSubnet1
PublicSubnet2Id:
Value: !Ref PublicSubnet2
VPCId3:
Value: !Ref DBVPC
PrivateSubnetId:
Value: !Ref PrivateSubnet

huangapple
  • 本文由 发表于 2023年4月17日 19:41:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76034794.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定