Encountered unsupported property VpcId

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

Encountered unsupported property VpcId

问题

以下是已翻译的内容:

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

  1. AWSTemplateFormatVersion: 2010-09-09
  2. Description: 此模板在公共子网中创建一个带有SSMEC2实例。
  3. Parameters:
  4. VPCId:
  5. Type: AWS::EC2::VPC::Id
  6. Description: 您现有的虚拟专用云(VPC)的VpcId
  7. Default: vpc-04ef73b29000f4f54
  8. PublicSubnet01Block:
  9. Type: AWS::EC2::Subnet::Id
  10. Description: 现有子网的SubnetId(用于虚拟专用云VPC中的主要网络)
  11. Default: subnet-0699037225107e8b2
  12. Resources:
  13. SSMIAMRole:
  14. Type: AWS::IAM::Role
  15. Properties:
  16. AssumeRolePolicyDocument:
  17. Statement:
  18. - Effect: Allow
  19. Principal:
  20. Service:
  21. - ec2.amazonaws.com
  22. Action:
  23. - sts:AssumeRole
  24. ManagedPolicyArns:
  25. - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
  26. EC2InstanceProfile:
  27. Type: AWS::IAM::InstanceProfile
  28. Properties:
  29. Path: /
  30. Roles:
  31. - !Ref SSMIAMRole
  32. Instance:
  33. Type: AWS::EC2::Instance
  34. Properties:
  35. IamInstanceProfile: !Ref EC2InstanceProfile
  36. ImageId: ami-0aa7d40eeae50c9a9
  37. VpcId: !Ref VPCId
  38. SubnetId: !Ref PublicSubnet01Block
  39. 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.

  1. AWSTemplateFormatVersion: 2010-09-09
  2. Description: This Template Create an EC2 in public subnet with SSM.
  3. Parameters:
  4. VPCId:
  5. Type: AWS::EC2::VPC::Id
  6. Description: VpcId of your existing Virtual Private Cloud (VPC)
  7. Default: vpc-04ef73b29000f4f54
  8. PublicSubnet01Block:
  9. Type: AWS::EC2::Subnet::Id
  10. Description: SubnetId of an existing subnet (for the primary network in your Virtual Private Cloud VPC)
  11. Default: subnet-0699037225107e8b2
  12. Resources:
  13. SSMIAMRole:
  14. Type: AWS::IAM::Role
  15. Properties:
  16. AssumeRolePolicyDocument:
  17. Statement:
  18. - Effect: Allow
  19. Principal:
  20. Service:
  21. - ec2.amazonaws.com
  22. Action:
  23. - sts:AssumeRole
  24. ManagedPolicyArns:
  25. - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
  26. EC2InstanceProfile:
  27. Type: AWS::IAM::InstanceProfile
  28. Properties:
  29. Path: /
  30. Roles:
  31. - !Ref SSMIAMRole
  32. Instance:
  33. Type: AWS::EC2::Instance
  34. Properties:
  35. IamInstanceProfile: !Ref EC2InstanceProfile
  36. ImageId: ami-0aa7d40eeae50c9a9
  37. VpcId: !Ref VPCId
  38. SubnetId: !Ref PublicSubnet01Block
  39. 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:

确定