Skip to content
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

[WIP] Continuous Deployment #1401

Merged
merged 10 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
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
15 changes: 0 additions & 15 deletions .circleci/config.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/apply.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: apply

on:
push:
branches:
- master

env:
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
AWS_DEFAULT_REGION: us-east-1

jobs:
apply:
name: apply
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

- name: terraform apply
uses: dflook/terraform-apply@v1
with:
path: terraform
env:
GITHUB_TOKEN: "${{ secrets.GH_SECRET_TOKEN }}"
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on every commit.
on:
push:


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Validate terraform (with the side-effect of installing the right
# version of terraform based on required_version constraints)
- name: validate
uses: dflook/terraform-validate@v1
with:
path: terraform

# Check terraform files are formatted correctly (terraform fmt -check)
- name: fmt
uses: dflook/terraform-fmt-check@v1
with:
path: terraform

# Runs terraform lint
- name: lint
uses: actionshub/terraform-lint@main

# Runs tfsec
- name: security scan
uses: triat/terraform-security-scan@v2.2.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Runs Checkov
- name: Run Checkov action
id: checkov
uses: bridgecrewio/checkov-action@master
with:
directory: terraform/
29 changes: 29 additions & 0 deletions .github/workflows/plan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: plan

on:
pull_request:
branches: [master]

env:
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
AWS_DEFAULT_REGION: us-east-1


jobs:
plan:
name: plan
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: checkout
uses: actions/checkout@v2

- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: terraform
env:
GITHUB_TOKEN: "${{ secrets.GH_SECRET_TOKEN }}"
9 changes: 5 additions & 4 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ To `plan`/`apply` changes:

Note that using a profile other than `Default` will mean you need to set the environment variable `AWS_PROFILE=profile_name` to the profile containing your tts-prod AWS credentials

1. [Install Terraform.](https://learn.hashicorp.com/tutorials/terraform/install-cli)
1. [Create a GitHub personal access token.](https://github.com/settings/tokens)
1. In this directory:
2. For CI/CD we setup a IAM profile and user with only those permissions to access from the created s3 bucket and dyanamodb table. See https://www.terraform.io/docs/language/settings/backends/s3.html#s3-bucket-permissions for the IAM JSON policy example.
3. [Install Terraform.](https://learn.hashicorp.com/tutorials/terraform/install-cli)
4. [Create a GitHub personal access token.](https://github.com/settings/tokens)
5. In this directory:

1. Create [a `terraform.tfvars` file](https://www.terraform.io/docs/configuration/variables.html#variable-definitions-tfvars-files) with the token

```hcl
github_token = "…"
```

1. Ensure Terraform runs successfuly
2. Ensure Terraform runs successfuly

```sh
terraform init
Expand Down
1 change: 0 additions & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ terraform {
}

provider "github" {
token = var.github_token
owner = "18f"
}

Expand Down
2 changes: 1 addition & 1 deletion terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "active_repos" {
description = "Used by rename_label.py"
value = [for repo, config in local.active_repos : repo]
value = [for repo, config in local.active_repos : repo]
}
2 changes: 1 addition & 1 deletion terraform/repo/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ locals {

# initiatives
"i: custom software" = {
color = local.label_colors.initiatives
color = local.label_colors.initiatives
# GH Label description is limited to 100 characters
description = "Relating to systems built in TTS and their need for tools, guidance, security authorization, etc."
}
Expand Down
3 changes: 0 additions & 3 deletions terraform/variables.tf

This file was deleted.