github.com/Tyktechnologies/tyk@v2.9.5+incompatible/aws/byol.pkr.hcl (about)

     1  # Generated by: tyk-ci/wf-gen
     2  # Generated on: Tuesday 23 February 2021 08:23:01 AM UTC
     3  
     4  # Generation commands:
     5  # ./pr.zsh -branch goreleaser/more -base goreleaser/more -title Removed: vol mount, compatibility symlink for pump -p
     6  # m4 -E -DxREPO=tyk
     7  
     8  variable "aws_access_key" {
     9    type      = string
    10    default   = "${env("AWS_ACCESS_KEY_ID")}"
    11    sensitive = true
    12  }
    13  
    14  variable "aws_secret_key" {
    15    type      = string
    16    default   = "${env("AWS_SECRET_ACCESS_KEY")}"
    17    sensitive = true
    18  }
    19  
    20  variable "flavour" {
    21    description = "OS Flavour"
    22    type    = string
    23  }
    24  
    25  variable "source_ami_owner" {
    26    type    = string
    27  }
    28  
    29  variable "ami_search_string" {
    30    type    = string
    31  }
    32  
    33  variable "geoip_license" {
    34    type    = string
    35    default = "${env("GEOIP_LICENSE")}"
    36  }
    37  
    38  variable "region" {
    39    type    = string
    40    default = "us-east-1"
    41  }
    42  
    43  variable "version" {
    44    type    = string
    45    default = "${env("VERSION")}"
    46  }
    47  
    48  # "timestamp" template function replacement
    49  locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
    50  
    51  # source blocks are generated from your builders; a source can be referenced in
    52  # build blocks. A build block runs provisioner and post-processors on a
    53  # source. Read the documentation for source blocks here:
    54  # https://www.packer.io/docs/from-1.5/blocks/source
    55  source "amazon-ebs" "byol" {
    56    access_key            = "${var.aws_access_key}"
    57    ami_name              = "BYOL tyk ${var.version} (${var.flavour})"
    58    ami_regions           = "${var.destination_regions}"
    59    ena_support           = true
    60    force_delete_snapshot = true
    61    force_deregister      = true
    62    instance_type         = "t3.micro"
    63    region                = "${var.region}"
    64    secret_key            = "${var.aws_secret_key}"
    65    source_ami            = "${var.source_ami}"
    66    source_ami_filter {
    67      filters = {
    68        architecture                       = "x86_64"
    69        "block-device-mapping.volume-type" = "gp2"
    70        name                               = "${var.ami_search_string}"
    71        root-device-type                   = "ebs"
    72        sriov-net-support                  = "simple"
    73        virtualization-type                = "hvm"
    74      }
    75      most_recent = true
    76      owners      = ["${var.source_ami_owner}"]
    77    }
    78    sriov_support = true
    79    ssh_username  = "ec2-user"
    80    subnet_filter {
    81      filters = {
    82        "tag:Class" = "build"
    83      }
    84      most_free = true
    85      random    = false
    86    }
    87    tags = {
    88      Component = "tyk"
    89      Flavour   = "${var.flavour}"
    90      Product   = "byol"
    91      Version   = "${var.version}"
    92    }
    93  }
    94  
    95  # a build block invokes sources and runs provisioning steps on them. The
    96  # documentation for build blocks can be found here:
    97  # https://www.packer.io/docs/from-1.5/blocks/build
    98  build {
    99    sources = ["source.amazon-ebs.byol"]
   100  
   101  
   102    provisioner "file" {
   103      destination = "/tmp/semver.sh"
   104      source      = "./semver.sh"
   105    }
   106    provisioner "file" {
   107      destination = "/tmp/10-run-tyk.conf"
   108      source      = "./10-run-tyk.conf"
   109    }
   110    provisioner "shell" {
   111      environment_vars = ["VERSION=${var.version}" , "GEOIP_LICENSE=${var.geoip_license}"]
   112      script           = "byol/install-tyk.sh"
   113    }
   114  }