From f5a4ca05edb49721ba674ad6172584ad61cbac44 Mon Sep 17 00:00:00 2001 From: Akash Agrawal Date: Wed, 14 Sep 2022 12:29:53 +0530 Subject: [PATCH] DOPS-101 Share packer ami between dops prod and sandbox --- bin/validate.sh | 4 ++-- packer/machines/web-server.json | 3 ++- terraform/variables.tf | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/validate.sh b/bin/validate.sh index 09adb63..de9caa4 100755 --- a/bin/validate.sh +++ b/bin/validate.sh @@ -2,7 +2,7 @@ # Set bash unofficial strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/ set -euo pipefail - + # Set DEBUG to true for enhanced debugging: run prefixed with "DEBUG=true" ${DEBUG:-false} && set -vx # Credit to https://stackoverflow.com/a/17805088 @@ -30,6 +30,7 @@ $DOCKER_PACKER validate app/packer/machines/web-server.json if [[ "${SKIP_TERRAFORM:-false}" == "false" ]]; then DOCKER_TERRAFORM=$(get_docker_terraform) fmt=$($DOCKER_TERRAFORM fmt) + echo "Linting terraform files for formatting" if [[ -n "$fmt" ]]; then echo 'ERROR: these files are not formatted correctly. Run "terraform fmt"' echo "$fmt" @@ -42,7 +43,6 @@ if [[ "${SKIP_TERRAFORM:-false}" == "false" ]]; then -var 'newrelic_license_key=ZZZZ' \ -var 'newrelic_api_key=ZZZZ' \ -var 'newrelic_alert_email=ferd.berferd@example.com' \ - echo "Linting terraform files for formatting" fi echo "Linting shell scripts" diff --git a/packer/machines/web-server.json b/packer/machines/web-server.json index 5194a59..92e678a 100644 --- a/packer/machines/web-server.json +++ b/packer/machines/web-server.json @@ -18,7 +18,8 @@ "vpc_id": "{{user `aws_vpc_id`}}", "ssh_username": "centos", "ami_name": "devops-infra-demo-centos-7-{{timestamp}}", - "ami_description": "DevOps Infrastructure Demo CentOS 7 - CIS hardened" + "ami_description": "DevOps Infrastructure Demo CentOS 7 - CIS hardened", + "ami_users": ["587267277416"] // Share with devops sandbox account }], "provisioners": [ { diff --git a/terraform/variables.tf b/terraform/variables.tf index 7932b59..770515f 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -48,9 +48,10 @@ variable "google_project" { default = "example-media" } +# Use devops prod account as default. We bake and store AMIs using packer. variable "aws_account_id_for_ami" { description = "AWS Account ID where AMIs live, if not the default" - default = "" + default = "191447213457" } variable "ami_pattern" {