How to change instance metadata with "AWS::EC2::Instance" when launching EC2 with CloudFormation

0

Hello.

I would like to set "IMDSv2" in the instance metadata option when creating an EC2 instance using CloudFormation.
Looking at the documentation below, it seems that you need to create a launch template.
However, I think it's a bit of a roundabout procedure to create a startup template when you just want to start up one EC2 machine.
How do you enable IMDSv2 when creating EC2 from CloudFormation?
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-IMDS-new-instances.html

I saw the GitHub issue below, but it didn't seem like any progress was being made.
https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/655

profile picture
ESPECIALISTA
feita há um mês491 visualizações
2 Respostas
1
Resposta aceita

Hi Riku,

Yes, it required a Launch template at this point until the issue you link to is fixed

But, to minimize your pain, you can find the proper template in this article: https://blog.karims.cloud/2020/11/15/practical-implemenation-of-imdsv2.html

Best,

Didier

profile pictureAWS
ESPECIALISTA
respondido há um mês
profile picture
ESPECIALISTA
avaliado há um mês
profile picture
ESPECIALISTA
avaliado há um mês
profile picture
ESPECIALISTA
avaliado há um mês
  • Thank you for your reply!

  • Riku, you are very welcome!

0

With the CDK, you can set the requireImdsv2 property to true when creating EC2 instances. For example:

new ec2.Instance(this, 'Instance', {
  requireImdsv2: true
})

By setting requireImdsv2 to true, any instances launched through the CloudFormation stack will only be able to use IMDSv2 to retrieve instance metadata. IMDSv1 will be disabled.

This allows you to enforce IMDSv2 for new EC2 instances in CloudFormation without needing to define a separate launch template. The CDK takes care of configuring the necessary instance metadata options behind the scenes.

https://docs.aws.amazon.com/drs/latest/userguide/set-imdsv2.html

profile picture
ESPECIALISTA
respondido há um mês

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas