hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
76 stars 112 forks source link

feat: add ignore failure in ami datasource #388

Closed galbirk closed 1 year ago

galbirk commented 1 year ago
  1. Added ignore_failure flag to ami datasource:
    • if true and the image not found -> returns nil
    • else - same as current behavior.

Defaulted to false.

  1. Some formatting required to pass github actions test.

Tests results:

$ make test
?       github.com/hashicorp/packer-plugin-amazon       [no test files]
ok      github.com/hashicorp/packer-plugin-amazon/builder/chroot        3.469s
ok      github.com/hashicorp/packer-plugin-amazon/builder/common        2.035s
?       github.com/hashicorp/packer-plugin-amazon/builder/common/awserrors      [no test files]
?       github.com/hashicorp/packer-plugin-amazon/builder/common/ssm    [no test files]
ok      github.com/hashicorp/packer-plugin-amazon/builder/ebs   13.905s
?       github.com/hashicorp/packer-plugin-amazon/builder/ebs/acceptance        [no test files]
ok      github.com/hashicorp/packer-plugin-amazon/builder/ebssurrogate  4.812s
ok      github.com/hashicorp/packer-plugin-amazon/builder/ebsvolume     3.097s
ok      github.com/hashicorp/packer-plugin-amazon/builder/instance      4.228s
ok      github.com/hashicorp/packer-plugin-amazon/datasource/ami        2.356s
ok      github.com/hashicorp/packer-plugin-amazon/datasource/parameterstore     3.011s
ok      github.com/hashicorp/packer-plugin-amazon/datasource/secretsmanager     2.710s
?       github.com/hashicorp/packer-plugin-amazon/post-processor/import [no test files]
?       github.com/hashicorp/packer-plugin-amazon/version       [no test files]

Closes #387

nywilken commented 1 year ago

Hi @galbirk thanks for opening up this PR and its corresponding issue. This particular solution while valid feels like a one off solution to a larger workflow problem around providing fallbacks when a data sources returns a failure. I'm going to close this pull-request as invalid, as this is not the approach we want to take. But I will keep the issue open because there is a workflow discussion we can have for supporting conditional to handle within a Packer template.

I will bring this issue internal to see if there is a workaround or potential workflow we can leverage at this time.