Giter VIP home page Giter VIP logo

terraform-codebuild-ec2-instance's Introduction

Terraform CodeBuild that Terraforms an EC2 Instance

Use Terraform to build a CodeBuild project that runs terraform as a build service

This little repo illustrates how to build a CodeBuild project with terraform and run terraform inside of this project to build infrastructure from another repo. This other repo builds a simple ec2 instance.

Config

Before running this terraform template add the following terraform config file.

Create a settings file terraform.auto.tfvars with the following:

echo <<< EOL
aws_access_key = "XXXXXXXXXXXXXXXXXXXX"
aws_secret_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
aws_region = "us-east-1"
public_key = "ssh-rsa AAAAB3NzaC1yc....9wrf+M7Q== [email protected]"
vpc_id = "vpc-00000000x00x0xxx0"
terraform_version = "0.9.9"
s3_bucket = "your-s3-bucket-terraform-state"
debug = "true"
EOL >> terraform.auto.tfvars;

terraform apply

After you're done creating the above file and adding your aws access key, secret and your ssh public key, run the following:

terraform init
terraform plan
echo yes | terraform apply

To remove what you built run:

echo yes | terraform destroy

The above terraform apply statement will create your CodeBuild project. After creating your project in AWS you should find your CodeBase project here: https://console.aws.amazon.com/codesuite/codebuild/projects?region=us-east-1 (Change your region in this URL to what you set your aws_region variable in your tfvars file to.)

This bit is manual in AWS Console

Your project in CodeBuild will look something like the image below:

Your CodeBuild project

Select your project and click Start Build: Start Build in AWS CodeBuild

Select Advanced build overrides: Advanced Build Overrides in AWS CodeBuild

Unfold Additional configuration and edit any of the environment variables. Set the DESTROY variable to true if you would like to run a build cycle that destroys your infrastructure. Advanced Build Overrides in AWS CodeBuild and build environment settings

Press Start Build.

And Bob's your uncle

You're done and have fun!

terraform-codebuild-ec2-instance's People

Contributors

randomtask2000 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.