-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from byu-oit/feature/ci
Feature/ci
- Loading branch information
Showing
5 changed files
with
115 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
types: [opened, reopened, synchronize, edited] | ||
env: | ||
tf_version: "0.12.26" # must match value in examples/ci/ci.tf | ||
|
||
jobs: | ||
env: | ||
name: Set Env Vars | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up DEV Environment Variables | ||
if: github.base_ref == 'master' | ||
run: | | ||
matrix='{ | ||
"env":[ | ||
{ | ||
"tf_working_dir":"./examples/ci", | ||
"aws_key_name":"byu_oit_terraform_dev_key", | ||
"aws_secret_name":"byu_oit_terraform_dev_secret" | ||
} | ||
] | ||
}' | ||
echo "::set-env name=matrix::`echo $matrix | jq -c .`" | ||
outputs: | ||
matrix: ${{ env.matrix }} | ||
|
||
format: | ||
name: Terraform Format | ||
runs-on: ubuntu-latest | ||
needs: env | ||
strategy: | ||
matrix: ${{ fromJson(needs.env.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Terraform Setup | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: ${{ env.tf_version }} | ||
|
||
- name: Terraform Format | ||
working-directory: "./" | ||
run: terraform fmt -check -recursive | ||
|
||
plan: | ||
name: Terraform Plan | ||
runs-on: ubuntu-latest | ||
needs: env | ||
strategy: | ||
matrix: ${{ fromJson(needs.env.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets[matrix.env.aws_key_name] }} | ||
aws-secret-access-key: ${{ secrets[matrix.env.aws_secret_name] }} | ||
aws-region: us-west-2 | ||
|
||
- name: Terraform Setup | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: ${{ env.tf_version }} | ||
|
||
- name: Terraform Init | ||
working-directory: ${{ matrix.env.tf_working_dir }} | ||
run: terraform init | ||
|
||
- name: Terraform Plan | ||
working-directory: ${{ matrix.env.tf_working_dir }} | ||
run: terraform plan -input=false | ||
# TODO: Post plan back to PR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
terraform { | ||
required_version = "0.12.26" | ||
} | ||
|
||
provider "aws" { | ||
version = "~> 2.42" | ||
region = "us-west-2" | ||
} | ||
|
||
module "backend_s3" { | ||
source = "../../" | ||
} | ||
|
||
output "s3_bucket" { | ||
value = module.backend_s3.s3_bucket | ||
} | ||
|
||
output "s3_bucket_name" { | ||
value = module.backend_s3.s3_bucket_name | ||
} | ||
|
||
output "lock_table" { | ||
value = module.backend_s3.lock_table | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
variable "bucket_name" { | ||
description = "Bucket name for the S3 bucket to store state files" | ||
default = "" | ||
default = "" | ||
} | ||
|
||
variable "dynamodb_table_name" { | ||
description = "DynamoDB table name for locking state files" | ||
default = "" | ||
default = "" | ||
} |