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

Set platform override in imagebuilder container recipe. #24712

Closed
wants to merge 31 commits into from
Closed

Set platform override in imagebuilder container recipe. #24712

wants to merge 31 commits into from

Conversation

chrisgilmerproj
Copy link

@chrisgilmerproj chrisgilmerproj commented May 9, 2022

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #24711

Output from acceptance testing:

Prerequisites: Export these environment variables:

$ export IMAGE_BUILDER_ECR_IMAGE_LINUX=public.ecr.aws/docker/library/python:3.9.12
$ export IMAGE_BUILDER_ECR_IMAGE_WINDOWS=public.ecr.aws/docker/library/python:3.9.12-windowsservercore-ltsc2022

And all the platform override tests:

$ make testacc TESTS=TestAccImageBuilderContainerRecipe_platform PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe_platform'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image (106.64s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override (106.86s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override (107.27s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux_without_override (107.59s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows (168.85s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux (168.97s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       175.449s

@github-actions github-actions bot added service/imagebuilder Issues and PRs that pertain to the imagebuilder service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. size/M Managed by automation to categorize the size of a PR. labels May 9, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @chrisgilmerproj 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels May 12, 2022
@chrisgilmerproj
Copy link
Author

@justinretzolk - I would really like to get some help finalizing this PR. It's a feature I need for production and if someone can give me some guidance I'm willing to do the rest of the work here. Can you help me find someone to partner with?

@justinretzolk
Copy link
Member

Hey @chrisgilmerproj 👋 First, thank you for taking the time to raise this PR! I'll reach out to some of our frequent contributors and see if I can get someone to take another look as well, but I've got a couple of resources that'll help you out.

One document that may help some is the contribution checklist for enhancements. Looking at that, you've got most of the things in order already, but you'll want to add a documentation update to document the new argument you've added.

You'll also want to add a changelog item. The process to do so is described here. There's also the common review items checklist that may be of use.

Finally, I'd be remiss if I didn't mention our prioritization guide to give you an idea of the lifecycle of the pull request itself.

@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label May 16, 2022
@chrisgilmerproj
Copy link
Author

@justinretzolk - Thanks for the help. I have added a changelog and docs as requested.

The thing I need help with is the acceptance test. To test this it requires an AWS ECR image is referenced. If the AWS ECR image does not exist then I think the test will fail. This code isn't making a cross-service call itself so the error is coming from AWS itself. Do you think someone has experience with this kind of problem before?

Copy link
Collaborator

@mattburgess mattburgess left a comment

Choose a reason for hiding this comment

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

@chrisgilmerproj - just FYI I'm not a maintainer but a contributor just like yourself. I happen to stick my nose in from time to time though to help with PR reviews and trying to guide folks where I can.

If you need a hand with the test case suggestion I make below, then I'm happy to, I just didn't want to hand-hold too much!

internal/service/imagebuilder/container_recipe.go Outdated Show resolved Hide resolved
internal/service/imagebuilder/container_recipe.go Outdated Show resolved Hide resolved
internal/service/imagebuilder/container_recipe_test.go Outdated Show resolved Hide resolved
internal/service/imagebuilder/container_recipe_test.go Outdated Show resolved Hide resolved
website/docs/r/imagebuilder_container_recipe.html.markdown Outdated Show resolved Hide resolved
@chrisgilmerproj
Copy link
Author

Thanks @mattburgess ! Your suggestions are really helpful. I've committed the ones that are straight forward. I'll go try to update the tests with your suggestion and see how far I get.

@chrisgilmerproj
Copy link
Author

@mattburgess - I ran a test and got an interesting result. I'm not sure how to import the platform_override info:

export IMAGE_BUILDER_ECR_IMAGE=public.ecr.aws/docker/library/python:3.9.12
make testacc TESTS=TestAccImageBuilderContainerRecipe_platform_override_linux PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe_platform_override_linux'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux
    container_recipe_test.go:549: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
        
        (map[string]string) {
        }
        
        
        (map[string]string) (len=1) {
         (string) (len=17) "platform_override": (string) (len=5) "Linux"
        }
--- FAIL: TestAccImageBuilderContainerRecipe_platform_override_linux (79.61s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       84.096s
FAIL
make: *** [testacc] Error 1

@mattburgess
Copy link
Collaborator

container_recipe_test.go:549: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.

That was a new one on me, but https://www.terraform.io/plugin/sdkv2/resources/import#importstateverifyignore-1 hints at the answer (and it's not to ignore the problem 😄) - I think you just need to update resourceContainerRecipeRead() around line 403 to set the value that's read back from the read operation.

@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels May 17, 2022
@chrisgilmerproj
Copy link
Author

It appears there's an issue with the windows version of this. The error I keep getting tells me to set the image_os_version_override. The problem with both platform_override and image_os_version_override is that they are values you can send during resource creation that don't come back when you read that same resource later. So I was able to manually use the windows image when creating a container recipe but it did not work from the SDK.

@chrisgilmerproj
Copy link
Author

For the error I'm seeing I tried to debug by making this change:

diff --git a/internal/service/imagebuilder/container_recipe.go b/internal/service/imagebuilder/container_recipe.go
index 5f2a62e5ed..ff193cb225 100644
--- a/internal/service/imagebuilder/container_recipe.go
+++ b/internal/service/imagebuilder/container_recipe.go
@@ -352,6 +352,7 @@ func resourceContainerRecipeCreate(d *schema.ResourceData, meta interface{}) err
        if v, ok := d.GetOk("working_directory"); ok {
                input.WorkingDirectory = aws.String(v.(string))
        }
+       fmt.Printf("%v\n", input)
 
        output, err := conn.CreateContainerRecipe(input)
 

The output looked like this:

$ make testacc TESTS=TestAccImageBuilderContainerRecipe_platform_override_windows PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe_platform_override_windows'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows
{
  ClientToken: "terraform-20220517235221519500000001",
  Components: [{
      ComponentArn: "arn:aws:imagebuilder:us-west-2:aws:component/update-windows/x.x.x"
    }],
  ContainerType: "DOCKER",
  DockerfileTemplateData: "FROM {{{ imagebuilder:parentImage }}}\n{{{ imagebuilder:environments }}}\n{{{ imagebuilder:components }}}\n",
  Name: "tf-acc-test-8124910467095321823",
  ParentImage: "public.ecr.aws/docker/library/python:3.9.12-windowsservercore-ltsc2022",
  PlatformOverride: "Windows",
  SemanticVersion: "1.0.0",
  TargetRepository: {
    RepositoryName: "tf-acc-test-8124910467095321823",
    Service: "ECR"
  }
}
    container_recipe_test.go:577: Step 1/2 error: Error running apply: exit status 1
        
        Error: error creating Image Builder Container Recipe: InvalidParameterCombinationException: The value supplied for parameter 'parentImage' is not valid. You must specify an image OsVersion override when using ECR Repositories as your parent image for Windows Platform.
        
          with aws_imagebuilder_container_recipe.test,
          on terraform_plugin_test.tf line 11, in resource "aws_imagebuilder_container_recipe" "test":
          11: resource "aws_imagebuilder_container_recipe" "test" {
        
--- FAIL: TestAccImageBuilderContainerRecipe_platform_override_windows (36.76s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       43.500s
FAIL
make: *** [testacc] Error 1

For some reason my image_os_version_override isn't being set properly in the test. If I can figure that out I might be good to go.

@chrisgilmerproj
Copy link
Author

Aha, fixed my problem. But now I'm stuck trying to recapture the data that isn't available:

$ make testacc TESTS=TestAccImageBuilderContainerRecipe_platform_override_windows PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe_platform_override_windows'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows
    container_recipe_test.go:577: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected.
        
        (map[string]string) {
        }
        
        
        (map[string]string) (len=1) {
         (string) (len=25) "image_os_version_override": (string) (len=29) "Microsoft Windows Server 2022"
        }
--- FAIL: TestAccImageBuilderContainerRecipe_platform_override_windows (82.36s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       87.399s
FAIL
make: *** [testacc] Error 1

@chrisgilmerproj
Copy link
Author

I've got the tests working now! It turns out that I can ignore the image_os_version_override parameter when comparing against the import. Because that info is not available once its been used.

This makes me think I should also do that for platform_override instead of trying to fake it's value on read by using platform. Do you have any thoughts?

@mattburgess
Copy link
Collaborator

I've got the tests working now! It turns out that I can ignore the image_os_version_override parameter when comparing against the import. Because that info is not available once its been used.

This makes me think I should also do that for platform_override instead of trying to fake it's value on read by using platform. Do you have any thoughts?

Yes, I think you might actually be right there. I see now that ContainerRecipe doesn't contain either of the _override attributes so I think this is a valid case of using ImportStateVerifyIgnore.

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels May 18, 2022
@chrisgilmerproj
Copy link
Author

@mattburgess - I think I've done it. I have a good set of tests in both the positive and negative. I also cleaned up the platform import that I had from before. I'd love to know if you were able to run my tests and if everything else looks good to you.

Copy link
Collaborator

@mattburgess mattburgess left a comment

Choose a reason for hiding this comment

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

Looking good, just some minor nits; will try and get the tests going shortly!

internal/acctest/acctest.go Outdated Show resolved Hide resolved
internal/service/imagebuilder/container_recipe.go Outdated Show resolved Hide resolved
.changelog/24712.txt Outdated Show resolved Hide resolved
@chrisgilmerproj
Copy link
Author

Just to be sure I didn't mess up the other tests:

 make testacc TESTS=TestAccImageBuilderContainerRecipe PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipeDataSource_arn
=== PAUSE TestAccImageBuilderContainerRecipeDataSource_arn
=== RUN   TestAccImageBuilderContainerRecipe_basic
=== PAUSE TestAccImageBuilderContainerRecipe_basic
=== RUN   TestAccImageBuilderContainerRecipe_disappears
=== PAUSE TestAccImageBuilderContainerRecipe_disappears
=== RUN   TestAccImageBuilderContainerRecipe_component
=== PAUSE TestAccImageBuilderContainerRecipe_component
=== RUN   TestAccImageBuilderContainerRecipe_componentParameter
=== PAUSE TestAccImageBuilderContainerRecipe_componentParameter
=== RUN   TestAccImageBuilderContainerRecipe_description
=== PAUSE TestAccImageBuilderContainerRecipe_description
=== RUN   TestAccImageBuilderContainerRecipe_dockerfileTemplateURI
=== PAUSE TestAccImageBuilderContainerRecipe_dockerfileTemplateURI
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_deviceName
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_deviceName
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_deleteOnTermination
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_deleteOnTermination
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_encrypted
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_encrypted
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_iops
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_iops
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_kmsKeyID
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_kmsKeyID
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_snapshotID
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_snapshotID
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeSize
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeSize
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeType
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeType
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_noDevice
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_noDevice
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_virtualName
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_virtualName
=== RUN   TestAccImageBuilderContainerRecipe_InstanceConfiguration_Image
=== PAUSE TestAccImageBuilderContainerRecipe_InstanceConfiguration_Image
=== RUN   TestAccImageBuilderContainerRecipe_kmsKeyID
=== PAUSE TestAccImageBuilderContainerRecipe_kmsKeyID
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== RUN   TestAccImageBuilderContainerRecipe_tags
=== PAUSE TestAccImageBuilderContainerRecipe_tags
=== RUN   TestAccImageBuilderContainerRecipe_workingDirectory
=== PAUSE TestAccImageBuilderContainerRecipe_workingDirectory
=== RUN   TestAccImageBuilderContainerRecipesDataSource_filter
=== PAUSE TestAccImageBuilderContainerRecipesDataSource_filter
=== CONT  TestAccImageBuilderContainerRecipeDataSource_arn
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_deviceName
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_snapshotID
=== CONT  TestAccImageBuilderContainerRecipe_componentParameter
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeType
=== CONT  TestAccImageBuilderContainerRecipesDataSource_filter
=== CONT  TestAccImageBuilderContainerRecipe_workingDirectory
=== CONT  TestAccImageBuilderContainerRecipe_tags
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux
=== CONT  TestAccImageBuilderContainerRecipe_kmsKeyID
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_Image
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_virtualName
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_noDevice
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_kmsKeyID
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeSize
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
    acctest.go:1019: skipping test for aws/us-west-2: Error running apply: exit status 1
        
        Error: error creating Image Builder Container Recipe: InvalidParameterCombinationException: The value supplied for parameter 'parentImage' is not valid. You must specify an image OsVersion override when using ECR Repositories as your parent image for Windows Platform.
        
          with aws_imagebuilder_container_recipe.test,
          on terraform_plugin_test.tf line 11, in resource "aws_imagebuilder_container_recipe" "test":
          11: resource "aws_imagebuilder_container_recipe" "test" {
        
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
    acctest.go:1019: skipping test for aws/us-west-2: Error running apply: exit status 1
        
        Error: error creating Image Builder Container Recipe: InvalidParameterCombinationException: The value supplied for parameter 'platformOverride' is not valid. You cannot specify a platform override when using an Image Builder Image as your parent.
        
          with aws_imagebuilder_container_recipe.test,
          on terraform_plugin_test.tf line 11, in resource "aws_imagebuilder_container_recipe" "test":
          11: resource "aws_imagebuilder_container_recipe" "test" {
        
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
    acctest.go:1019: skipping test for aws/us-west-2: Error running apply: exit status 1
        
        Error: error creating Image Builder Container Recipe: InvalidParameterCombinationException: The value supplied for parameter 'parentImage' is not valid. You must specify a platform override when using ECR Public Repositories as your parent image.
        
          with aws_imagebuilder_container_recipe.test,
          on terraform_plugin_test.tf line 11, in resource "aws_imagebuilder_container_recipe" "test":
          11: resource "aws_imagebuilder_container_recipe" "test" {
        
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
    acctest.go:1019: skipping test for aws/us-west-2: Error running apply: exit status 1
        
        Error: error creating Image Builder Container Recipe: InvalidParameterCombinationException: The value supplied for parameter 'parentImage' is not valid. You must specify a platform override when using ECR Public Repositories as your parent image.
        
          with aws_imagebuilder_container_recipe.test,
          on terraform_plugin_test.tf line 11, in resource "aws_imagebuilder_container_recipe" "test":
          11: resource "aws_imagebuilder_container_recipe" "test" {
        
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_iops
--- SKIP: TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override (235.64s)
--- SKIP: TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override (242.76s)
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_encrypted
--- SKIP: TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image (244.52s)
=== CONT  TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_deleteOnTermination
--- SKIP: TestAccImageBuilderContainerRecipe_platform_override_linux_without_override (245.84s)
=== CONT  TestAccImageBuilderContainerRecipe_dockerfileTemplateURI
--- PASS: TestAccImageBuilderContainerRecipesDataSource_filter (389.43s)
=== CONT  TestAccImageBuilderContainerRecipe_disappears
--- PASS: TestAccImageBuilderContainerRecipeDataSource_arn (397.36s)
=== CONT  TestAccImageBuilderContainerRecipe_component
=== CONT  TestAccImageBuilderContainerRecipe_basic
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_kmsKeyID (507.79s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux (512.26s)
=== CONT  TestAccImageBuilderContainerRecipe_description
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeSize (512.45s)
--- PASS: TestAccImageBuilderContainerRecipe_workingDirectory (513.30s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_volumeType (514.39s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows (514.89s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_deviceName (518.36s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_snapshotID (526.01s)
--- PASS: TestAccImageBuilderContainerRecipe_componentParameter (526.52s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_virtualName (535.75s)
--- PASS: TestAccImageBuilderContainerRecipe_kmsKeyID (538.09s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMapping_noDevice (538.84s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_Image (539.84s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_encrypted (376.41s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_iops (385.16s)
--- PASS: TestAccImageBuilderContainerRecipe_InstanceConfiguration_BlockDeviceMappingEBS_deleteOnTermination (387.66s)
--- PASS: TestAccImageBuilderContainerRecipe_dockerfileTemplateURI (387.68s)
--- PASS: TestAccImageBuilderContainerRecipe_disappears (244.21s)
--- PASS: TestAccImageBuilderContainerRecipe_component (260.99s)
--- PASS: TestAccImageBuilderContainerRecipe_basic (170.08s)
--- PASS: TestAccImageBuilderContainerRecipe_description (168.76s)
--- PASS: TestAccImageBuilderContainerRecipe_tags (695.67s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       700.202s

Copy link
Collaborator

@mattburgess mattburgess left a comment

Choose a reason for hiding this comment

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

Nearly there 😄 - tests are passing for me with one exception noted below. I can't test the Windows variant of these tests though as I can't pull and push Windows images without a Windows machine.

internal/acctest/acctest.go Outdated Show resolved Hide resolved
internal/acctest/acctest.go Outdated Show resolved Hide resolved
internal/service/imagebuilder/container_recipe_test.go Outdated Show resolved Hide resolved
@chrisgilmerproj
Copy link
Author

I've done an update and now the tests look like:

$ make testacc TESTS=TestAccImageBuilderContainerRecipe_platform PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe_platform'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image (106.64s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override (106.86s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override (107.27s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux_without_override (107.59s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows (168.85s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux (168.97s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       175.449s

@chrisgilmerproj
Copy link
Author

I just rebased this on main so it stays up to date.

@chrisgilmerproj
Copy link
Author

Checking in on this. Is it possible to get someone to review it?

@chrisgilmerproj
Copy link
Author

Another check in. Hoping to see some traction on this.

@justinretzolk
Copy link
Member

Hey @chrisgilmerproj 👋 Thank you for checking in on this. Unfortunately, I'm not able to provide an estimate on when this will be merged/reviewed due to the potential of shifting priorities (we prioritize work by count of ":+1:" reactions, as well as a few other things). For more information on how we prioritize, check out out prioritization guide. As a note, you won't need to worry about rebasing to keep the branch up to date; we won't let that affect the prioritization, and if any rebasing is needed at review time, the maintainers will gladly take care of that.

@chrisgilmerproj
Copy link
Author

Thanks @justinretzolk - I'll work on finding more folks to add "👍" reactions so we can get this prioritized.

@chrisgilmerproj
Copy link
Author

@LightningStairs thanks for the approval! Do I need to resolve conflicts on this branch for you?

@sf-mporte
Copy link

is there any updates on this PR being merged in?

@chrisgilmerproj
Copy link
Author

@sf-mporte - I have not heard any news on getting this merged. I wish I had more info for you.

@samwyma
Copy link
Contributor

samwyma commented Apr 6, 2023

@chrisgilmerproj I included this change in my recent PR (#30398) as I needed it to write some acceptance tests. My PR has been merged and the changes are set to be included in v4.62.0!

@chrisgilmerproj
Copy link
Author

@chrisgilmerproj I included this change in my recent PR (#30398) as I needed it to write some acceptance tests. My PR has been merged and the changes are set to be included in v4.62.0!

@samwyma thanks for helping me get these changes into the code base! I do appreciate it as I would like to have these features available and I've been waiting a long time. I would have liked it more if my contributions had also made it into the repo with my username attached. I was looking forward to showing my team and my friends that I had actually contributed to this provider but now the git blame will not show my work. That's especially disappointing after all the time I invested into this change. Maybe next time it would be a good idea to cherry-pick the commits and then modify them as needed for your own PR.

@sf-mporte
Copy link

@chrisgilmerproj I included this change in my recent PR (#30398) as I needed it to write some acceptance tests. My PR has been merged and the changes are set to be included in v4.62.0!

So glad to hear! thank you!

@sf-mporte
Copy link

@chrisgilmerproj I included this change in my recent PR (#30398) as I needed it to write some acceptance tests. My PR has been merged and the changes are set to be included in v4.62.0!

@samwyma thanks for helping me get these changes into the code base! I do appreciate it as I would like to have these features available and I've been waiting a long time. I would have liked it more if my contributions had also made it into the repo with my username attached. I was looking forward to showing my team and my friends that I had actually contributed to this provider but now the git blame will not show my work. That's especially disappointing after all the time I invested into this change. Maybe next time it would be a good idea to cherry-pick the commits and then modify them as needed for your own PR.

Thank you for your work on this! i hope you get the credit you deserve

@chrisgilmerproj
Copy link
Author

chrisgilmerproj commented Apr 6, 2023

Thank you for your work on this! i hope you get the credit you deserve

I appreciate it. I noticed the PR #30398 didn't include all of the test cases that I provided in this MR. I'll update the tests and perhaps you can help me get them merged in.

@chrisgilmerproj
Copy link
Author

@sf-mporte @samwyma @LightningStairs @justinretzolk - I have updated this MR to include the most recent changes from main and #30398 . The tests are updated and passing. The tests included here ensure that the platform_override option also works for Windows as well as Linux. And the docs are updated appropriately.

Is it possible to get this reviewed and merged as well to go out in the v4.62.0 release? or the following release? Thank you.

Test results below:

$ make testacc TESTS=TestAccImageBuilderContainerRecipe_platform PKG=imagebuilder
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderContainerRecipe_platform'  -timeout 180m
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== RUN   TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== PAUSE TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== RUN   TestAccImageBuilderContainerRecipe_platformOverride
=== PAUSE TestAccImageBuilderContainerRecipe_platformOverride
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_without_override
=== CONT  TestAccImageBuilderContainerRecipe_platformOverride
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image
=== CONT  TestAccImageBuilderContainerRecipe_platform_override_windows
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows_without_platform_override (9.84s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux_without_override (9.95s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows_without_image_os_version_override (9.98s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux_wrong_parent_image (10.90s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_linux (21.39s)
--- PASS: TestAccImageBuilderContainerRecipe_platformOverride (22.20s)
--- PASS: TestAccImageBuilderContainerRecipe_platform_override_windows (22.47s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder       25.464s

@samwyma
Copy link
Contributor

samwyma commented Apr 7, 2023

@gdavison This is an extension to the PR you merged for me yesterday which makes the platform_override setting work for Windows (which I didn't test). Would you be able to review these changes?

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/imagebuilder Issues and PRs that pertain to the imagebuilder service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EC2 Image Builder Container Recipe should support Platform Override
6 participants