Hello Seems what you want is just a CI worker and AWS cli
packer is a tool that bulild VMs/AMIs/Docker primarily. you could add a manifest post processor, and grab de AMI created there and just delete it if you don't need it On Wed, Aug 7, 2019 at 10:09 PM Dean Kayton <[email protected]> wrote: > It seems that Packer was only designed for specific build artifacts, > Docker images and AMIs for example. > > What I want is for Packer to spin up an instance with a specific IAM role > in my own VPC, build Docker images and push to ECR. Also copy the compiled > source code to an s3 bucket. Even copy certain files back to the CI tool to > be used on subsequent builds. > > This is all very manageable with Packer, except it annoyingly insists on > saving an AMI at the end. Why is there no way of skipping that final step!? > This has got me thinking that maybe I am using the wrong tool. > > If so what is the correct tool? Is there maybe a Terraform module that can > do the same? Years ago, I hacked around and ended up making a set of > Terraform templates that worked with Gitlab CI for example. > > > Here is an example of a Gitlab CI template that works: > > > stages: > - build > .ci: &ci | > wget > https://raw.githubusercontent.com/dnk8n/remote-provisioner/master/src/terraform/terraform.aws.main.tf > terraform init > terraform apply -auto-approve=true || JOB_STATUS=$? > terraform destroy -auto-approve=true > exit ${JOB_STATUS:-0} > variables: > TF_VAR_region: eu-west-1 > TF_VAR_iam_instance_profile: builder > build-example: > stage: build > image: > name: hashicorp/terraform:0.12.5 > entrypoint: [""] > variables: > TF_VAR_file_or_dir_source: ${CI_PROJECT_DIR}/ > TF_VAR_file_or_dir_dest: /home/ubuntu/ > TF_VAR_remote_command: '["chmod +x /home/ubuntu/path/to/build.sh", > "/home/ubuntu/path/to/build.sh"]' > TF_VAR_instance_type: t3a.micro > TF_VAR_timeout_minutes: '10' > script: > - *ci > > > > The following requirements are assumed: > > - *${CI_PROJECT_DIR}/path/to/build.sh* exists, where ${CI_PROJECT_DIR} is > the root of your repo > - You want to send all the contents of your repo ( > TF_VAR_file_or_dir_source) to /home/ubuntu on the remote instance ( > TF_VAR_file_or_dir_dest) and you don't need anything else for the build > > More explanation at https://github.com/dnk8n/remote-provisioner > > I would honestly love to use Packer instead, but then skip the creation of > AMIs which are unnecessary for my use case. I could use Packer directly in > the CI tool to create a Docker image, but often that gives issues (because > of CI tools running as docker containers themselves. It would be nice to > have a 'remote-docker' Packer builder which works in a similar way to the > ebs-builder but results in a Docker image in ECR instead of an AMI. > > -- > This mailing list is governed under the HashiCorp Community Guidelines - > https://www.hashicorp.com/community-guidelines.html. Behavior in > violation of those guidelines may result in your removal from this mailing > list. > > GitHub Issues: https://github.com/mitchellh/packer/issues > IRC: #packer-tool on Freenode > --- > You received this message because you are subscribed to the Google Groups > "Packer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/packer-tool/bcddfa06-ff8d-45d7-8bdc-7be593a21ce4%40googlegroups.com > <https://groups.google.com/d/msgid/packer-tool/bcddfa06-ff8d-45d7-8bdc-7be593a21ce4%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Alvaro -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/packer/issues IRC: #packer-tool on Freenode --- You received this message because you are subscribed to the Google Groups "Packer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0ewOSew9%3Du%2BsH1B2Fvs%2BSfAXyB1GmNoEK%3DS1fsF%3D9WjQsw%40mail.gmail.com.
