Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2: how to specify 'MetaData' for the instance? #25885

Closed
1 of 2 tasks
sonaliks opened this issue Jun 7, 2023 · 5 comments
Closed
1 of 2 tasks

ec2: how to specify 'MetaData' for the instance? #25885

sonaliks opened this issue Jun 7, 2023 · 5 comments
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@sonaliks
Copy link

sonaliks commented Jun 7, 2023

Describe the feature

The "CfnInstance" Construct documentation[1] does not define how to specify 'MetaData' for the instance. And the "addMetadata(key, value)" construct can have only key-pair values while the instance metadata has to be quite large.

The solution that worked is using "addOverride" function:

As per Link[2] you can make use of "addOverride" function to add metadata to a 'CfnInstance' construct. An example[3] is as follows:


asgLaunchConfig.addOverride("Metadata", {
"AWS::CloudFormation::Init": {
"FOO": "BAR",
}
});

However ask from Service team:

  1. Kindly add a method in CDK "CfnInstance" construct to be able to add large metadata. this is apart from "addMetadata" method.
  2. If the "addOverride" should be the only method then kindly update the documentation[1] and mention this as this is not properly documented and is a common usecase.

[1] https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnInstance.html
[2] https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnInstance.html#addwbrmetadatakey-value
[3] #5087
[4] #777

Use Case

NA

Proposed Solution

NA

Other Information

NA

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

V2

Environment details (OS name and version, etc.)

MAC

@sonaliks sonaliks added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 7, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Jun 7, 2023
@pahud pahud mentioned this issue Jun 7, 2023
@pahud pahud self-assigned this Jun 7, 2023
@pahud
Copy link
Contributor

pahud commented Jun 7, 2023

What metadata are you trying to add for the ec2 instance? Is it instance metadata? If yes, I am afraid cloudformation does not allow you to add MetadataOptions to ec2 instance and this is tracking in cloudformation coverage roadmap here.

However, you may specify MetadataOptions in CfnLaunchConfiguration or in LauchTemplateDataProperty.

Is this something you are looking for?

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 7, 2023
@pahud pahud removed their assignment Jun 7, 2023
@pahud pahud added the effort/medium Medium work item – several days of effort label Jun 7, 2023
@pahud pahud changed the title (CfnInstance): (how to specify 'MetaData' for the instance?) ec2: how to specify 'MetaData' for the instance? Jun 7, 2023
@github-actions
Copy link

github-actions bot commented Jun 9, 2023

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 9, 2023
@sonaliks
Copy link
Author

Thank you @pahud for your response. I understand that "cloudformation does not allow you to add MetadataOptions to ec2 instance" however i was able to add the metadata using "addOverride" function. Further "CfnInstance" is equivalent to "AWS::EC2::Instance" in CloudFormation. As per doc[1] the "AWS::EC2::Instance" Resource type does support CFN Metadata. I have tested same in Cloudformation and it works.

However in CDK "CfnInstance" resource "addMetadata(key, value)" construct can have only key-pair values while the instance metadata has to be quite large.

Hence asking for a native function for same in "CfnInstance" resource.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jun 10, 2023
@pahud
Copy link
Contributor

pahud commented Jun 13, 2023

Please note the addMetadata() in the CfnInstance API reference is essentially to add CloudFormation Resource Metadata instead of EC2 instance metadata options. If you look at AWS::EC2::Instance there's no property that allows you to specify instance metadata options. If you really need to specify instance metadata options I believe you will need to specify that either in LauchConfiguration or LaunchTemplate as described above.

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jun 13, 2023
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants