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

add base ami choice to packer json and Makefiles #921

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ packer-linux-amd64.output: $(PACKER_LINUX_FILES)
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-e SOURCE_AMI_NAME_FILTER \
-e SOURCE_AMI_OWNER \
-e PACKER_LOG \
-v ${HOME}/.aws:/root/.aws \
-v "$(PWD):/src" \
--rm \
-w /src/packer/linux \
hashicorp/packer:$(PACKER_VERSION) build -timestamp-ui -var 'region=$(AWS_REGION)' \
-var 'arch=x86_64' -var 'goarch=amd64' -var 'instance_type=$(AMD64_INSTANCE_TYPE)' \
-var 'source_ami_name_filter=$(SOURCE_AMI_NAME_FILTER)' \
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this override the default value from the variables section with an empty string if the environment variable isn’t set?

-var 'source_ami_owner=$(SOURCE_AMI_OWNER)' \
buildkite-ami.json | tee $@

build/linux-arm64-ami.txt: packer-linux-arm64.output env-AWS_REGION
Expand All @@ -103,13 +107,17 @@ packer-linux-arm64.output: $(PACKER_LINUX_FILES)
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-e SOURCE_AMI_NAME_FILTER \
-e SOURCE_AMI_OWNER \
-e PACKER_LOG \
-v ${HOME}/.aws:/root/.aws \
-v "$(PWD):/src" \
--rm \
-w /src/packer/linux \
hashicorp/packer:$(PACKER_VERSION) build -timestamp-ui -var 'region=$(AWS_REGION)' \
-var 'arch=arm64' -var 'goarch=arm64' -var 'instance_type=$(ARM64_INSTANCE_TYPE)' \
-var 'source_ami_name_filter=$(SOURCE_AMI_NAME_FILTER)' \
-var 'source_ami_owner=$(SOURCE_AMI_OWNER)' \
buildkite-ami.json | tee $@

build/windows-amd64-ami.txt: packer-windows-amd64.output env-AWS_REGION
Expand All @@ -124,12 +132,16 @@ packer-windows-amd64.output: $(PACKER_WINDOWS_FILES)
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_SESSION_TOKEN \
-e SOURCE_AMI_NAME_FILTER \
-e SOURCE_AMI_OWNER \
-e PACKER_LOG \
-v ${HOME}/.aws:/root/.aws \
-v "$(PWD):/src" \
--rm \
-w /src/packer/windows \
hashicorp/packer:$(PACKER_VERSION) build -timestamp-ui -var 'region=$(AWS_REGION)' \
-var 'source_ami_name_filter=$(SOURCE_AMI_NAME_FILTER)' \
-var 'source_ami_owner=$(SOURCE_AMI_OWNER)' \
buildkite-ami.json | tee $@

# -----------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions packer/linux/buildkite-ami.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"variables": {
"source_ami_name_filter": "amzn2-ami-hvm-2.0.*-gp2",
"source_ami_owner": "amazon",
"region": "us-east-1",
"arch": "x86_64",
"goarch": "amd64",
Expand All @@ -12,11 +14,11 @@
"region": "{{user `region`}}",
"source_ami_filter": {
"filters": {
"name": "amzn2-ami-hvm-2.0.*-gp2",
"name": "{{user `source_ami_name_filter`}}",
"architecture": "{{user `arch`}}",
"virtualization-type": "hvm"
},
"owners": ["amazon"],
"owners": "{{user `source_ami_owner`}}",
"most_recent": true
},
"instance_type": "{{user `instance_type`}}",
Expand Down
6 changes: 4 additions & 2 deletions packer/windows/buildkite-ami.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"variables": {
"source_ami_name_filter": "Windows_Server-2019-English-Full-Containers*",
"source_ami_owner": "amazon",
"region": "us-east-1"
},
"builders": [
Expand All @@ -8,10 +10,10 @@
"region": "{{user `region`}}",
"source_ami_filter": {
"filters": {
"name": "Windows_Server-2019-English-Full-Containers*",
"name": "{{user `source_ami_name_filter`}}",
"virtualization-type": "hvm"
},
"owners": ["amazon"],
"owners": "{{user `source_ami_owner`}}",
"most_recent": true
},
"instance_type": "m5.xlarge",
Expand Down