Skip to content

Commit

Permalink
Include deprecated AMIs when creating light stemcell
Browse files Browse the repository at this point in the history
After a max of 2 years, AWS "deprecates" public AMIs, which means that
they do not show up in `DescribeImages` API calls.  (You can still use
them as long as you know their ID)

This leads to an error like the following when using > 2-year-old (and
therefore deprecated) stemcell AMIs:
```
bosh us https://bosh.io/d/stemcells/bosh-aws-xen-hvm-ubuntu-xenial-go_agent?v=621.125
Using environment '10.0.16.10' as client 'ops_manager'

Task 10

Task 10 | 23:24:10 | Update stemcell: Downloading remote stemcell (00:00:01)
Task 10 | 23:24:11 | Update stemcell: Verifying remote stemcell (00:00:00)
Task 10 | 23:24:11 | Update stemcell: Extracting stemcell archive (00:00:00)
Task 10 | 23:24:11 | Update stemcell: Verifying stemcell manifest (00:00:00)
Task 10 | 23:24:16 | Update stemcell: Checking if this stemcell already exists (cpi: 543ec2c1aa4f72578fa3) (00:00:00)
Task 10 | 23:24:16 | Update stemcell: Uploading stemcell bosh-aws-xen-hvm-ubuntu-xenial-go_agent/621.125 to the cloud (cpi: 543ec2c1aa4f72578fa3) (00:00:02)
                   L Error: CPI error 'Bosh::Clouds::CloudError' with message 'Stemcell does not contain an AMI in region us-west-1' in 'create_stemcell' CPI method (CPI request ID: 'cpi-457127')
Task 10 | 23:24:18 | Error: CPI error 'Bosh::Clouds::CloudError' with message 'Stemcell does not contain an AMI in region us-west-1' in 'create_stemcell' CPI method (CPI request ID: 'cpi-457127')

Task 10 Started  Wed Nov 15 23:24:10 UTC 2023
Task 10 Finished Wed Nov 15 23:24:18 UTC 2023
Task 10 Duration 00:00:08
Task 10 error

Uploading remote stemcell 'https://bosh.io/d/stemcells/bosh-aws-xen-hvm-ubuntu-xenial-go_agent?v=621.125':
  Expected task '10' to succeed but state is 'error'

Exit code 1
```

Even though the CPI knows the exact AMI ID of the stemcell image, it
makes a `DescribeImages` call when creating a light stemcell.  The AWS SDK
allows for an `include_deprecated` option when making the call, and
adding that option solves the issue.

Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-deprecate.html

[#186468123]
  • Loading branch information
selzoc committed Nov 15, 2023
1 parent 6b23ba6 commit fe649d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bosh_aws_cpi/lib/cloud/aws/cloud_v1.rb
Expand Up @@ -376,7 +376,8 @@ def create_stemcell(image_path, stemcell_properties)
filters: [{
name: 'image-id',
values: props.ami_ids
}]
}],
include_deprecated: true,
).first
raise Bosh::Clouds::CloudError, "Stemcell does not contain an AMI in region #{@config.aws.region}" unless available_image

Expand Down

0 comments on commit fe649d3

Please sign in to comment.