Skip to content

Commit 8553d99

Browse files
committed
Provide first github action
1 parent d6e009c commit 8553d99

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed

.github/workflows/terraform.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Deploy
2+
on: [push, pull_request]
3+
jobs:
4+
deploy-infrastructure:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: hashicorp/setup-terraform@v3
9+
10+
- name: Prepare
11+
run: |
12+
terraform init
13+
terraform plan
14+

infrastructure/health/health.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
2-
app_name = "strikes"
3-
lambda_name = "health_lambda"
2+
app_name = "strikes"
3+
lambda_name = "health_lambda"
44
}
55

66
data "aws_iam_policy_document" "lambda_assume_role" {
@@ -13,17 +13,17 @@ data "aws_iam_policy_document" "lambda_assume_role" {
1313
}
1414

1515
actions = ["sts:AssumeRole"]
16-
}
16+
}
1717
}
1818

1919
resource "aws_iam_role" "lambda_role" {
20-
name = "${local.app_name}-${local.lambda_name}"
21-
assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json
20+
name = "${local.app_name}-${local.lambda_name}"
21+
assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json
2222
}
2323

2424
resource "aws_iam_role_policy_attachment" "basic_execution_role_policy_attachment" {
25-
role = aws_iam_role.lambda_role.name
26-
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
25+
role = aws_iam_role.lambda_role.name
26+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
2727
}
2828

2929
data "archive_file" "lambda_archive" {

infrastructure/main.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ terraform {
66
}
77
}
88
backend "s3" {
9-
bucket = "tf-backend-state-strikes"
10-
encrypt = true
9+
bucket = "tf-backend-state-strikes"
10+
encrypt = true
1111
dynamodb_table = "tf-backend-lock-strikes"
12-
key = "terraform.tfstate"
13-
region = "eu-central-1"
12+
key = "terraform.tfstate"
13+
region = "eu-central-1"
1414
}
1515
}
1616

1717
provider "aws" {
18-
region = "eu-central-1"
18+
region = "eu-central-1"
1919
profile = "cc"
2020
}
2121

@@ -34,26 +34,26 @@ resource "aws_api_gateway_resource" "health" {
3434
}
3535

3636
resource "aws_api_gateway_method" "health" {
37-
authorization = "NONE"
38-
http_method = "GET"
39-
resource_id = aws_api_gateway_resource.health.id
40-
rest_api_id = aws_api_gateway_rest_api.strikes.id
41-
api_key_required = true
37+
authorization = "NONE"
38+
http_method = "GET"
39+
resource_id = aws_api_gateway_resource.health.id
40+
rest_api_id = aws_api_gateway_rest_api.strikes.id
41+
api_key_required = true
4242
}
4343

4444
resource "aws_api_gateway_integration" "health" {
45-
http_method = aws_api_gateway_method.health.http_method
46-
resource_id = aws_api_gateway_resource.health.id
47-
rest_api_id = aws_api_gateway_rest_api.strikes.id
48-
type = "AWS_PROXY"
45+
http_method = aws_api_gateway_method.health.http_method
46+
resource_id = aws_api_gateway_resource.health.id
47+
rest_api_id = aws_api_gateway_rest_api.strikes.id
48+
type = "AWS_PROXY"
4949
integration_http_method = "POST"
50-
uri = "${module.health.lambda_invoke_arn}"
50+
uri = module.health.lambda_invoke_arn
5151
}
5252

5353
resource "aws_lambda_permission" "apigw_invoke_health_lambda" {
5454
statement_id = "AllowAPIGatewayInvoke"
5555
action = "lambda:InvokeFunction"
56-
function_name = "${module.health.lambda_function_name}"
56+
function_name = module.health.lambda_function_name
5757
principal = "apigateway.amazonaws.com"
5858

5959
source_arn = "${aws_api_gateway_rest_api.strikes.execution_arn}/*/*"
@@ -83,7 +83,7 @@ resource "aws_api_gateway_stage" "strikes" {
8383
deployment_id = aws_api_gateway_deployment.strikes.id
8484
rest_api_id = aws_api_gateway_rest_api.strikes.id
8585

86-
stage_name = "v1"
86+
stage_name = "v1"
8787
}
8888

8989
resource "aws_api_gateway_usage_plan" "strikes" {

infrastructure/remote-state/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ resource "aws_s3_bucket" "tf_backend_state" {
1515
bucket = "tf-backend-state-strikes"
1616
}
1717

18-
1918
resource "aws_s3_bucket_versioning" "tf_backend_state_versioning" {
2019
bucket = aws_s3_bucket.tf_backend_state.id
2120
versioning_configuration {

0 commit comments

Comments
 (0)