Skip to content
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
4 changes: 1 addition & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
code:
Expand All @@ -13,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: CodeForPoznan/actions/setup-infrastructure@v2
with:
terraform-version: 1.5.3
terraform-version: 1.12.0

- run: make check

Expand Down
124 changes: 62 additions & 62 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ Repository contains description of Code for Poznań infrastructure.
You'll need AWS credentials into our organization and a tunnel to our bastion server
in order to work with this code. This can't be done unless you've been added by one of admins (see ./admins.tf file).

#### version used

```shell
terraform version
Terraform v1.5.2
on darwin_arm64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.19.0
+ provider registry.terraform.io/hashicorp/aws v5.7.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.3.2
+ provider registry.terraform.io/hashicorp/random v3.5.1
```


#### Initialize project

```
Expand Down
9 changes: 7 additions & 2 deletions codeforpoznan_pl_v3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ module "codeforpoznan_pl_v3_cloudfront_distribution" {
origin_path = "/codeforpoznan_pl_v3"
}
api_gateway = {
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.codeforpoznan_pl_v3_serverless_api.deployment.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.codeforpoznan_pl_v3_serverless_api.deployment.invoke_url).path
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.codeforpoznan_pl_v3_serverless_api.stage.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.codeforpoznan_pl_v3_serverless_api.stage.invoke_url).path
custom_origin = true
}
}
Expand All @@ -137,6 +137,11 @@ module "codeforpoznan_pl_v3_cloudfront_distribution" {
]
}

import {
to = module.codeforpoznan_pl_v3_serverless_api.aws_api_gateway_stage.stage
id = "q4ih7hkyl4/devel"
}

module "codeforpoznan_pl_v3_serverless_api" {
source = "./serverless_api"

Expand Down
2 changes: 1 addition & 1 deletion db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_db_instance" "db" {
identifier = "main-postgres"

engine = "postgres"
engine_version = "12.17"
engine_version = "12.19"

instance_class = "db.t3.micro"
allocated_storage = 8
Expand Down
9 changes: 7 additions & 2 deletions dev_codeforpoznan_pl_v3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ resource "aws_iam_user_policy_attachment" "dev_codeforpoznan_pl_v3_ses_policy_at
user = module.dev_codeforpoznan_pl_v3_user.user.name
}

import {
to = module.dev_codeforpoznan_pl_v3_serverless_api.aws_api_gateway_stage.stage
id = "z00svsc3od/devel"
}

module "dev_codeforpoznan_pl_v3_serverless_api" {
source = "./serverless_api"

Expand Down Expand Up @@ -153,8 +158,8 @@ module "dev_codeforpoznan_pl_v3_cloudfront_distribution" {
origin_path = "/dev_codeforpoznan_pl_v3"
}
api_gateway = {
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_codeforpoznan_pl_v3_serverless_api.deployment.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_codeforpoznan_pl_v3_serverless_api.deployment.invoke_url).path
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_codeforpoznan_pl_v3_serverless_api.stage.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_codeforpoznan_pl_v3_serverless_api.stage.invoke_url).path
custom_origin = true
}
}
Expand Down
9 changes: 7 additions & 2 deletions dev_pah_fm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ module "dev_pah_fm_frontend_assets" {
iam_user = module.dev_pah_fm_user.user
}

import {
to = module.dev_pah_fm_serverless_api.aws_api_gateway_stage.stage
id = "8sbwf5qbi1/devel"
}

module "dev_pah_fm_serverless_api" {
source = "./serverless_api"

Expand Down Expand Up @@ -112,8 +117,8 @@ module "dev_pah_fm_cloudfront_distribution" {
origin_path = "/dev_pah_fm"
}
api_gateway = {
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_pah_fm_serverless_api.deployment.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_pah_fm_serverless_api.deployment.invoke_url).path
domain_name = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_pah_fm_serverless_api.stage.invoke_url).hostname
origin_path = regex("https://(?P<hostname>[^/?#]*)(?P<path>[^?#]*)", module.dev_pah_fm_serverless_api.stage.invoke_url).path
custom_origin = true
}
}
Expand Down
10 changes: 5 additions & 5 deletions providers.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.5.0"
required_version = "~> 1.12.0"

backend "s3" {
bucket = "codeforpoznan-tfstate"
Expand All @@ -11,20 +11,20 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.61.0"
version = "5.98.0"
configuration_aliases = [aws.north_virginia]
}
random = {
source = "hashicorp/random"
version = "3.6.2"
version = "3.7.2"
}
cloudinit = {
source = "hashicorp/cloudinit"
version = "2.3.4"
version = "2.3.7"
}
postgresql = {
source = "cyrilgdn/postgresql"
version = "1.19.0"
version = "1.25.0"
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions serverless_api/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,27 @@ resource "aws_api_gateway_integration" "proxy_integration" {

resource "aws_api_gateway_deployment" "deployment" {
rest_api_id = aws_api_gateway_rest_api.rest_api.id
stage_name = "devel"

depends_on = [
aws_api_gateway_integration.root_integration,
aws_api_gateway_integration.proxy_integration,
]
}

resource "aws_api_gateway_stage" "stage" {
deployment_id = aws_api_gateway_deployment.deployment.id
rest_api_id = aws_api_gateway_rest_api.rest_api.id
stage_name = "devel"
}

resource "aws_lambda_permission" "permission" {
function_name = module.lambda.function.function_name
statement_id = "${replace(title(replace(var.name, "/[\\._]/", " ")), " ", "")}Invoke"
action = "lambda:InvokeFunction"
principal = "apigateway.amazonaws.com"
source_arn = "${replace(aws_api_gateway_deployment.deployment.execution_arn, "devel", "")}*/*"
source_arn = "${replace(aws_api_gateway_stage.stage.execution_arn, "devel", "")}*/*"
}

output "deployment" {
value = aws_api_gateway_deployment.deployment
output "stage" {
value = aws_api_gateway_stage.stage
}