Skip to content

Commit a1e20e6

Browse files
committed
add ci
1 parent 672455a commit a1e20e6

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
types: [opened, reopened, synchronize, edited]
7+
env:
8+
tf_version: "0.12.26" # must match value in examples/ci/ci.tf
9+
10+
jobs:
11+
env:
12+
name: Set Env Vars
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Set up DEV Environment Variables
16+
if: github.base_ref == 'master'
17+
run: |
18+
matrix='{
19+
"env":[
20+
{
21+
"tf_working_dir":"./examples/ci",
22+
"aws_key_name":"byu_oit_terraform_dev_key",
23+
"aws_secret_name":"byu_oit_terraform_dev_secret"
24+
}
25+
]
26+
}'
27+
echo "::set-env name=matrix::`echo $matrix | jq -c .`"
28+
29+
outputs:
30+
matrix: ${{ env.matrix }}
31+
32+
format:
33+
name: Terraform Format
34+
runs-on: ubuntu-latest
35+
needs: env
36+
strategy:
37+
matrix: ${{ fromJson(needs.env.outputs.matrix) }}
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Terraform Setup
42+
uses: hashicorp/setup-terraform@v1
43+
with:
44+
terraform_version: ${{ env.tf_version }}
45+
46+
- name: Terraform Format
47+
working-directory: "./"
48+
run: terraform fmt -check -recursive
49+
50+
plan:
51+
name: Terraform Plan
52+
runs-on: ubuntu-latest
53+
needs: env
54+
strategy:
55+
matrix: ${{ fromJson(needs.env.outputs.matrix) }}
56+
steps:
57+
- uses: actions/checkout@v2
58+
59+
- name: Configure AWS credentials
60+
uses: aws-actions/configure-aws-credentials@v1
61+
with:
62+
aws-access-key-id: ${{ secrets[matrix.env.aws_key_name] }}
63+
aws-secret-access-key: ${{ secrets[matrix.env.aws_secret_name] }}
64+
aws-region: us-west-2
65+
66+
- name: Terraform Setup
67+
uses: hashicorp/setup-terraform@v1
68+
with:
69+
terraform_version: ${{ env.tf_version }}
70+
71+
- name: Terraform Init
72+
working-directory: ${{ matrix.env.tf_working_dir }}
73+
run: terraform init
74+
75+
- name: Terraform Plan
76+
working-directory: ${{ matrix.env.tf_working_dir }}
77+
run: terraform plan -input=false
78+
# TODO: Post plan back to PR

examples/ci/ci.tf

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
terraform {
2+
required_version = "0.12.26"
3+
}
4+
5+
provider "aws" {
6+
version = "~> 2.56"
7+
region = "us-west-2"
8+
}
9+
10+
module "acs" {
11+
source = "github.com/byu-oit/terraform-aws-acs-info?ref=v2.1.0"
12+
}
13+
14+
module "lambda_api" {
15+
source = "../../"
16+
app_name = "my-lambda"
17+
env = "dev"
18+
lambda_zip_file = "./lambda.zip"
19+
handler = "index.handler"
20+
runtime = "nodejs12.x"
21+
hosted_zone = module.acs.route53_zone
22+
https_certificate_arn = module.acs.certificate.arn
23+
vpc_id = module.acs.vpc.id
24+
public_subnet_ids = module.acs.public_subnet_ids
25+
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
26+
27+
lambda_vpc_config = {
28+
subnet_ids = module.acs.private_subnet_ids
29+
security_group_ids = []
30+
}
31+
}
32+
33+
output "lambda" {
34+
value = module.lambda_api.lambda
35+
}
36+
37+
output "lambda_security_group" {
38+
value = module.lambda_api.lambda_security_group
39+
}
40+
41+
output "lambda_live_alias" {
42+
value = module.lambda_api.lambda_live_alias
43+
}
44+
45+
output "codedeploy_deployment_group" {
46+
value = module.lambda_api.codedeploy_deployment_group
47+
}
48+
49+
output "codedeploy_appspec_json_file" {
50+
value = module.lambda_api.codedeploy_appspec_json_file
51+
}
52+
53+
output "alb" {
54+
value = module.lambda_api.alb
55+
}
56+
57+
output "alb_security_group" {
58+
value = module.lambda_api.alb_security_group
59+
}
60+
61+
output "dns_record" {
62+
value = module.lambda_api.dns_record
63+
}
64+
65+
output "cloudwatch_log_group" {
66+
value = module.lambda_api.cloudwatch_log_group
67+
}

examples/ci/lambda.zip

Whitespace-only changes.

0 commit comments

Comments
 (0)