Encountered unsupported property VpcId

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

Encountered unsupported property VpcId

问题

以下是已翻译的内容:

"我正在编写一个CloudFormation模板,用于在EC2实例上安装SSM代理。但是当我将模板上传到CloudFormation时,出现了名为Encountered unsupported property VpcId的错误。"

AWSTemplateFormatVersion: 2010-09-09

Description: 此模板在公共子网中创建一个带有SSM的EC2实例。

Parameters:
  VPCId:
    Type: AWS::EC2::VPC::Id
    Description: 您现有的虚拟专用云(VPC)的VpcId
    Default: vpc-04ef73b29000f4f54 

  PublicSubnet01Block:
    Type: AWS::EC2::Subnet::Id
    Description: 现有子网的SubnetId(用于虚拟专用云VPC中的主要网络)
    Default: subnet-0699037225107e8b2 

Resources:
  SSMIAMRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
        - Effect: Allow
          Principal:
            Service:
              - ec2.amazonaws.com
          Action:
            - sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore

  EC2InstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Path: /
      Roles:
        - !Ref SSMIAMRole

  Instance:
    Type: AWS::EC2::Instance
    Properties:
      IamInstanceProfile: !Ref EC2InstanceProfile
      ImageId: ami-0aa7d40eeae50c9a9
      VpcId: !Ref VPCId
      SubnetId: !Ref PublicSubnet01Block
      InstanceType: t2.micro

我明白您正在处理的模板。如果您需要更多帮助,可以继续提问。

英文:

I am writing a cloud formation template that install SSM agent in EC2. but when i upload the template in Cfn. I got the error called Encountered unsupported property VpcId.

AWSTemplateFormatVersion: 2010-09-09

Description: This Template Create an EC2 in public subnet with SSM.

Parameters:
  VPCId:
    Type: AWS::EC2::VPC::Id
    Description: VpcId of your existing Virtual Private Cloud (VPC)
    Default: vpc-04ef73b29000f4f54 

  PublicSubnet01Block:
    Type: AWS::EC2::Subnet::Id
    Description: SubnetId of an existing subnet (for the primary network in your Virtual Private Cloud VPC)
    Default: subnet-0699037225107e8b2 

Resources:
  SSMIAMRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
        - Effect: Allow
          Principal:
            Service:
              - ec2.amazonaws.com
          Action:
            - sts:AssumeRole
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore


  EC2InstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Path: /
      Roles:
        - !Ref SSMIAMRole

  Instance:
    Type: AWS::EC2::Instance
    Properties:
      IamInstanceProfile: !Ref EC2InstanceProfile
      ImageId: ami-0aa7d40eeae50c9a9
      VpcId: !Ref VPCId
      SubnetId: !Ref PublicSubnet01Block
      InstanceType: t2.micro
      

I am not sure what else to try. Here is the template I am working with..

答案1

得分: 2

错误相当明显,根据参考文档VpcId 不是 CloudFormation 中 EC2 实例的支持参数。相反,您可以指定一个 SubnetId(似乎您已经这样做了!),这将使其放置在您想要的 VPC 中,因为子网与 VPC 相关联。

英文:

The error is pretty self explanatory, VpcId is not a supported parameter for EC2 instances in cloudformation according to the reference documentation. Instead, you can specify a SubnetId (which it seems like you've done!) and that will place it in the VPC you want, since subnets are associated with VPCs.

huangapple
  • 本文由 发表于 2023年3月31日 02:49:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75891950.html
匿名

发表评论

匿名网友

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

确定