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

Added support for new command line parameter --disable-imds-v1 to disable IMDSv1 for Elastic BeanStalk environments. #323

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

ashishdhingra
Copy link
Contributor

@ashishdhingra ashishdhingra commented Jun 20, 2024

Issue #, if available: #290 (internal issue: DOTNET-7165)

Description of changes:
Adds feature to disable IMDSv1 by default for new Elastic BeanStalk environments. Also adds support for new command line parameter --disable-imds-v1 useful for updating existing environments.

Refer https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-ec2-imds.html#environments-cfg-ec2-imds.namespace for details on how to disable IMDSv1.

EDIT: (Per review comment from @normj) We should not disable IMDSv1 by default for new environments since it could break existing users using legacy Visual Studio tooling. The AWS Toolkit for Visual Studio doesn't have checkbox for the new flag and hence users might not know if IMDSv1 is being disabled by default.

Testing:
The changes were tested in personal AWS account (via Visual Studio debugging and observing state in AWS EB console) for below scenarios (executed AWS .NET Extensions CLI command):

  • Create new EB environment with --disable-imds-v1 set to true.
  • Created EB environment with default settings, which could enable IMDSv1.
    • Re-deployed the EB environment with --disable-imds-v1 set to true. This executed update EB environment scenario and disabled IMDSv1.

After this PR is released we also need to create PR to push CLI extensions changes to AWS Toolkit for Visual Studio repository and thereafter their team could decide to add GUI checkbox for the new setting.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ashishdhingra ashishdhingra added feature-request A feature should be added or improved. module/cli-ext labels Jun 20, 2024
@dscpinheiro dscpinheiro requested a review from normj June 25, 2024 17:35


// For new environments, disable IMDSv1 by default (unless explicitly enabled in additional options).
createRequest.OptionSettings.Add(new ConfigurationOptionSetting()
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to be both the here and in AddAdditionalOptions? Seems redundant and you had to add code in AddAdditionalOptions to handle the fact that it was potentially added by the parent caller.

Copy link
Member

Choose a reason for hiding this comment

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

I misunderstood the purpose here which was to force all new deployments to have disable to true. We don't want to do that because that could break users and we don't have a UI element in Visual Studio for users to toggle this.

@ashishdhingra is going to change the logic to remove this section and in the AddAdditionalOptions only set the disable if the user explicitly set the field. The VS toolkit can decide if they want to add a checkbox users can see and default the value to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the default disabling of IMDSv1 since it could break existing customers using legacy Visual Studio tooling. Also simplified code in AddAdditionalOptions to not check if existing setting is already added.

@@ -92,6 +93,8 @@ internal void ParseCommandArguments(CommandOptions values)
this.LoadBalancerType = tuple.Item2.StringValue;
if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_ENABLE_STICKY_SESSIONS.Switch)) != null)
this.EnableStickySessions = tuple.Item2.BoolValue;
if ((tuple = values.FindCommandOption(EBDefinedCommandOptions.ARGUMENT_DISABLE_IMDS_V1.Switch)) != null)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in latest commit

@ashishdhingra ashishdhingra force-pushed the user/ashdhin/eb-disableimdsv1-issue290 branch from 821a787 to 3147d66 Compare June 25, 2024 19:08
@ashishdhingra ashishdhingra changed the title Adds feature to disable IMDSv1 by default for new Elastic BeanStalk environments. Also adds support for new command line parameter --disable-imds-v1 useful for updating existing environments. Adds support for new command line parameter --disable-imds-v1 to disable IMDSv1 for Elastic BeanStalk environments. Jun 25, 2024
@ashishdhingra ashishdhingra requested a review from normj June 25, 2024 19:14
@ashishdhingra ashishdhingra changed the title Adds support for new command line parameter --disable-imds-v1 to disable IMDSv1 for Elastic BeanStalk environments. Added support for new command line parameter --disable-imds-v1 to disable IMDSv1 for Elastic BeanStalk environments. Jun 25, 2024
…able IMDSv1 for Elastic BeanStalk environments.
@ashishdhingra ashishdhingra force-pushed the user/ashdhin/eb-disableimdsv1-issue290 branch from 3147d66 to a801761 Compare June 25, 2024 19:16
@ashishdhingra ashishdhingra added the p1 This is a high priority issue label Jun 26, 2024
Copy link
Member

@ashovlin ashovlin left a comment

Choose a reason for hiding this comment

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

Changes look fine, but can you add details to the PR description about how you tested it?

We do have some tests asserting against boolean options, such as here:

Assert.Equal(xraySetting.Value.ToLower(), "true");

@ashishdhingra ashishdhingra requested a review from ashovlin June 27, 2024 17:10
@ashishdhingra
Copy link
Contributor Author

Changes look fine, but can you add details to the PR description about how you tested it?

We do have some tests asserting against boolean options, such as here:

Assert.Equal(xraySetting.Value.ToLower(), "true");

@ashovlin Added details on how this was tested. Please review.

@ashishdhingra ashishdhingra merged commit d9670b0 into dev Jul 2, 2024
2 checks passed
@ashishdhingra ashishdhingra deleted the user/ashdhin/eb-disableimdsv1-issue290 branch July 2, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. module/cli-ext p1 This is a high priority issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants