Skip to content

Build #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
.terraform

44 changes: 44 additions & 0 deletions app_build/terraform/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
terraform {
backend "s3" {
bucket = "grx-core-tfstate"
key = "aws-codebuild-docker-images"
region = "us-east-1"
dynamodb_table = "cybergrx-tflock"
}
}

provider "aws" {
alias = "core"
region = "${var.region}"

assume_role {
role_arn = "arn:aws:iam::${lookup(var.account_numbers, "core")}:role/terraform-role"
}
}

provider "aws" {
alias = "main"
region = "${var.region}"

assume_role {
role_arn = "arn:aws:iam::${lookup(var.account_numbers, "main")}:role/terraform-role"
}
}

provider "aws" {
region = "${var.region}"

assume_role {
role_arn = "arn:aws:iam::${lookup(var.account_numbers, var.env)}:role/terraform-role"
}
}

data "terraform_remote_state" "vpc" {
backend = "s3"

config {
bucket = "grx-core-tfstate"
key = "vpc"
region = "us-east-1"
}
}
20 changes: 20 additions & 0 deletions app_build/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module "build_pipe" {
source = "git::ssh://git@github.com/CyberGRX/terraform-aws-grx-codebuild.git?ref=v1.3.19"
region = "${var.region}"
vpc_id = "${lookup(data.terraform_remote_state.vpc.vpc_id,var.env)}"
private_subnets = ["${data.terraform_remote_state.vpc.private_subnets["${var.env}"]}"]
project_name = "aws-codebuild-docker-images"
create_pipe = "yes"
include_ecr = "yes"
env = "core"
build_image = "aws/codebuild/standard:2.0"

parameter_list = [
"/build/secrets/daedalus",
"/codebuild/nexus/helm-password",
]

providers = {
aws.core = "aws.core"
}
}
25 changes: 25 additions & 0 deletions app_build/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#Boiler Plate Variables
variable "account_numbers" {
description = "Map of account numbers matched to environement"
type = "map"

default = {
main = "551321121225"
staging = "001096032920"
core = "746807083977"
dev = "122189113537"
prod = "528335337478"
}
}

variable "env" {
description = "The environment to deploy into"
type = "string"
default = "core"
}

variable "region" {
description = "The AWS region"
type = "string"
default = "us-east-1"
}
12 changes: 11 additions & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
version: 0.2

phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
$(aws ecr get-login --no-include-email --region us-east-1)
build:
commands:
- cd $CODEBUILD_SRC_DIR/ubuntu/standard/2.0
- docker build -t aws/codebuild/standard:2.0 .
- docker build -t aws-codebuild-docker .
post_build:
commands:
- docker tag aws-codebuild-docker:latest 746807083977.dkr.ecr.us-east-1.amazonaws.com/$PROJECT:latest
- docker push 746807083977.dkr.ecr.us-east-1.amazonaws.com/$PROJECT:latest
Loading