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: MachineImages that use SSM queries get unwantedly replaced on deployments #5675

Closed
phillipCouto opened this issue Jan 7, 2020 · 2 comments · Fixed by #6065
Closed
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud docs/inline Related to inline documentation of the API Reference feature-request A feature should be added or improved. guidance Question that needs advice or information. in-progress This issue is being actively worked on. p2

Comments

@phillipCouto
Copy link
Contributor

General Issue

I currently have a CDK project with many stacks in them and the issue I am having is I have one stack that is a generic load balancer shared between applications and the other is an EC2 instance that is accessed through the load balancer. I am making a change to the load balancer but the CDK deploy function seems to run the deploy on any stacks that have resources referenced by my load balancer stack. The EC2 instance stack has no changes and when I run cdk diff on that stack it shows no changes but when I run deploy on the EC2 stack or on the load balancer stack which runs deploy on the EC2 stack it detects the AMI for the latest version of windows is different and tries to replace my instance. The issue is I deployed the EC2 stack back in November which for my region used AMI ami-07d23537f44fe67c1 but now the latest version in my region is ami-06eed5c2539ba3e74. I am using the ca-central-1 region.

I feel like this is a bug as I can't see why an EC2 instance should be replaced after deployment just because the latest AMI was updated.

Environment

  • CDK CLI Version: 1.19.0
  • Module Version: 1.19.0
  • OS: macOS 10.15.2
  • Language: Typescript
@SomayaB SomayaB added bug This issue is a bug. guidance Question that needs advice or information. @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 8, 2020

That is fair. As a workaround, you can use GenericWindowsImage which takes an AMI map:

new GenericWindowsImage({
  'ca-central-1': 'ami-07d23537f44fe67c1'
});

@rix0rrr rix0rrr changed the title ec2 instance using WindowsImage is being replaced when nothing changed ec2: MachineImages that use SSM queries get unwantedly replaced on deployments Jan 8, 2020
@rix0rrr rix0rrr added the p2 label Jan 8, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 8, 2020

To fix this:

  • Make it clear in the documentation that this type of image will always be up to date and may cause replacements.
  • Direct people to LookupMachineImage.
  • Make a MachineImage class with static factories to mirror the enum-like pattern and an easy way to discover the different types of images they can use.

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jan 15, 2020
@rix0rrr rix0rrr added feature-request A feature should be added or improved. docs/inline Related to inline documentation of the API Reference guidance Question that needs advice or information. and removed bug This issue is a bug. guidance Question that needs advice or information. labels Jan 23, 2020
rix0rrr added a commit that referenced this issue Feb 3, 2020
Some MachineImages get updated automatically (causing unexpected
instance replacement), and some don't. Update the documentation to very
clearly note which image is which, and that using a particular type of
image may cause your instance to be replaced.

Also add a class with static factory functions to make an enum-like
pattern, to be in line with other places where the user has a choice
of implementations.

Fixes #5675.

Also note that VPC lookups are cached, which hopefully addresses #6025.
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Feb 3, 2020
@mergify mergify bot closed this as completed in #6065 Feb 5, 2020
mergify bot added a commit that referenced this issue Feb 5, 2020
…6065)

Some MachineImages get updated automatically (causing unexpected
instance replacement), and some don't. Update the documentation to very
clearly note which image is which, and that using a particular type of
image may cause your instance to be replaced.

Also add a class with static factory functions to make an enum-like
pattern, to be in line with other places where the user has a choice
of implementations.

Fixes #5675.

Also note that VPC lookups are cached, which hopefully addresses #6025.

Co-authored-by: netanir <neta1nir@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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 docs/inline Related to inline documentation of the API Reference feature-request A feature should be added or improved. guidance Question that needs advice or information. in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants