Skip to content

add metadata options to launch template creation#168

Closed
juser0719 wants to merge 0 commit into
DevopsArtFactory:mainfrom
juser0719:main
Closed

add metadata options to launch template creation#168
juser0719 wants to merge 0 commit into
DevopsArtFactory:mainfrom
juser0719:main

Conversation

@juser0719
Copy link
Copy Markdown
Contributor

Description
This PR enforces IMDSv2 (Instance Metadata Service Version 2) for all EC2 instances deployed via goployer by adding metadata options to the launch template configuration.

Changes:

  • Added MetadataOptions field to CreateNewLaunchTemplate function in pkg/aws/ec2.go
  • Set HttpTokens: "required" to enforce IMDSv2 token-based authentication
  • Set HttpPutResponseHopLimit: 1 for additional security hardening
  • Set HttpEndpoint: "enabled" to keep metadata service accessible

Security Benefits:

  • Prevents SSRF (Server-Side Request Forgery) attacks targeting IMDS
  • Requires session tokens for metadata access, improving security posture
  • Aligns with AWS security best practices and compliance requirements

User facing changes
Before:

  • EC2 instances deployed with IMDSv1 enabled by default
  • Metadata accessible via simple HTTP requests without authentication

After:

  • All newly deployed EC2 instances automatically use IMDSv2
  • Metadata access requires token-based authentication
  • Existing manifest files require no changes

Comment thread pkg/aws/ec2.go Outdated
Monitoring: &ec2.LaunchTemplatesMonitoringRequest{Enabled: aws.Bool(detailedMonitoringEnabled)},
MetadataOptions: &ec2.LaunchTemplateInstanceMetadataOptionsRequest{
HttpTokens: aws.String("required"),
HttpPutResponseHopLimit: aws.Int64(1),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hop limit을 조정해야하는 경우도 있으니 변수로 할당 받되 명시 안하면 1로 지정하는건 어때요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpPutResponseHopLimit 의 경우 optional로 받아오도록 수정했습니다! 리뷰 부탁드립니다!

Copy link
Copy Markdown
Contributor

@Chaaany Chaaany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@YoungJinJung YoungJinJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@YoungJinJung
Copy link
Copy Markdown
Contributor

test code도 만들어주세요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants