Skip to content

Commit 2e46c2d

Browse files
[build-image] Add internal parameter to distinguish official AMI build
This allows more complete AMI cleanup when build official AMIs Signed-off-by: Hanwen <[email protected]>
1 parent 5c5ad98 commit 2e46c2d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

cli/src/pcluster/resources/imagebuilder/parallelcluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ phases:
329329
commands:
330330
- |
331331
set -v
332-
/usr/local/sbin/ami_cleanup.sh
332+
/usr/local/sbin/ami_cleanup.sh "${CfnParamIsOfficialAmiBuild}"
333333
334334
- name: validate
335335
steps:

cli/src/pcluster/templates/imagebuilder_stack.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,25 @@ def _add_cfn_parameters(self):
213213
),
214214
description="UpdateOsAndReboot",
215215
)
216+
CfnParameter(
217+
self,
218+
"CfnParamIsOfficialAmiBuild",
219+
type="String",
220+
default=(
221+
json.loads(self.config.dev_settings.cookbook.extra_chef_attributes)
222+
.get("cluster")
223+
.get("is_official_ami_build")
224+
if self.config.dev_settings
225+
and self.config.dev_settings.cookbook
226+
and self.config.dev_settings.cookbook.extra_chef_attributes
227+
and json.loads(self.config.dev_settings.cookbook.extra_chef_attributes).get("cluster")
228+
and json.loads(self.config.dev_settings.cookbook.extra_chef_attributes)
229+
.get("cluster")
230+
.get("is_official_ami_build")
231+
else "false"
232+
),
233+
description="IsOfficialAmiBuild",
234+
)
216235

217236
# -- Resources --------------------------------------------------------------------------------------------------- #
218237

0 commit comments

Comments
 (0)