From 49786e28dbe098f34823866cf90b0b96559b1105 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 15 Feb 2023 11:53:38 +0100 Subject: [PATCH] Pass the revision down from ssm --- packer/docs-rs-builder/builder.pkr.hcl | 11 ++++++++++- packer/docs-rs-builder/variables.pkr.hcl | 4 ---- packer/packer | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 packer/docs-rs-builder/variables.pkr.hcl diff --git a/packer/docs-rs-builder/builder.pkr.hcl b/packer/docs-rs-builder/builder.pkr.hcl index c78146d21..99168e02e 100644 --- a/packer/docs-rs-builder/builder.pkr.hcl +++ b/packer/docs-rs-builder/builder.pkr.hcl @@ -7,8 +7,16 @@ packer { } } +data "amazon-parameterstore" "revision" { + name = "/docs-rs/builder/sha" +} + +locals { + revision = data.amazon-parameterstore.revision.value +} + source "amazon-ebs" "ubuntu" { - ami_name = "docs-rs-builder-${var.revision}" + ami_name = "docs-rs-builder-${local.revision}" instance_type = "t2.large" region = "us-east-1" source_ami_filter { @@ -41,5 +49,6 @@ build { playbook_file = "./play/playbook.yml" # The default is the user running packer user = "ubuntu" + extra_arguments = [ "--extra-vars", "vars_repository_sha=${local.revision}"] } } diff --git a/packer/docs-rs-builder/variables.pkr.hcl b/packer/docs-rs-builder/variables.pkr.hcl deleted file mode 100644 index 49928dd2c..000000000 --- a/packer/docs-rs-builder/variables.pkr.hcl +++ /dev/null @@ -1,4 +0,0 @@ -variable "revision" { - type = string - description = "the revision of the builder to build" -} \ No newline at end of file diff --git a/packer/packer b/packer/packer index b0864fc9d..d5a8ed127 100755 --- a/packer/packer +++ b/packer/packer @@ -51,7 +51,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("env") parser.add_argument("playbook") - parser.add_argument('--var', action='append', help='Ansible variables as $key=$value') + parser.add_argument('--var', action='append', help='Ansible variables as $key=$value', default=[]) args = parser.parse_args() workspace = create_workspace(args.env, args.playbook)