Skip to content

Commit

Permalink
change aws_provider version back to 3.37.0, revert deprecation warnin…
Browse files Browse the repository at this point in the history
…g changes from feature/batch to be in accordance with old 3.37.0 implementation.
  • Loading branch information
avrohomgottlieb committed Nov 22, 2024
1 parent 600cf09 commit 1703f1f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 50 deletions.
5 changes: 3 additions & 2 deletions infrastructure/api-configuration/environment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ DATABASE_PORT=${database_port}
DATABASE_USER=${database_user}
DATABASE_NAME=${database_name}
DATABASE_PASSWORD=${database_password}
AWS_BATCH_JOB_QUEUE_NAME=${aws_batch_job_queue_name}
AWS_BATCH_JOB_DEFINITION_NAME=${aws_batch_job_definition_name}
# TODO: enable batch
# AWS_BATCH_JOB_QUEUE_NAME
# AWS_BATCH_JOB_DEFINITION_NAME
AWS_REGION=${aws_region}
AWS_S3_BUCKET_NAME=${aws_s3_bucket_name}
SENTRY_DSN=${sentry_dsn}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resource "aws_instance" "api_server_1" {
database_host = aws_db_instance.postgres_db.address
database_port = aws_db_instance.postgres_db.port
database_user = aws_db_instance.postgres_db.username
database_name = aws_db_instance.postgres_db.db_name
database_name = aws_db_instance.postgres_db.name
database_password = var.database_password
# TODO: enable batch
# aws_batch_job_queue_name = module.batch.job_queue_name
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "aws_db_instance" "postgres_db" {
engine_version = "12.19"
auto_minor_version_upgrade = false
instance_class = var.database_instance_type
db_name = "scpca_portal"
name = "scpca_portal"
port = "5432"
username = "scpcapostgresuser"
password = var.database_password
Expand Down
1 change: 1 addition & 0 deletions infrastructure/init_terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def init_terraform(env, user):
command = [
"terraform",
"init",
"-upgrade",
init_bucket,
init_key,
"-backend-config=dynamodb_table=scpca-portal-terraform-lock",
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/networking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ resource "aws_db_subnet_group" "scpca_portal" {

# Get the API a static IP address.
resource "aws_eip" "scpca_portal_api_ip" {
domain = "vpc"
vpc = true

tags = merge(
var.default_tags,
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.0.0"
version = "3.37.0"

}
}
Expand Down
56 changes: 13 additions & 43 deletions infrastructure/s3.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resource "aws_s3_bucket" "scpca_portal_bucket" {
bucket = "scpca-portal-${var.user}-${var.stage}"
acl = "private"
force_destroy = var.stage == "prod" ? false : true

tags = merge(
Expand All @@ -11,20 +12,6 @@ resource "aws_s3_bucket" "scpca_portal_bucket" {
)
}

resource "aws_s3_bucket_ownership_controls" "scpca_portal_bucket" {
bucket = aws_s3_bucket.scpca_portal_bucket.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_acl" "scpca_portal_bucket" {
depends_on = [aws_s3_bucket_ownership_controls.scpca_portal_bucket]

bucket = aws_s3_bucket.scpca_portal_bucket.id
acl = "private"
}

resource "aws_s3_bucket_public_access_block" "scpca_portal_bucket" {
bucket = aws_s3_bucket.scpca_portal_bucket.id

Expand All @@ -34,44 +21,27 @@ resource "aws_s3_bucket_public_access_block" "scpca_portal_bucket" {

resource "aws_s3_bucket" "scpca_portal_cert_bucket" {
bucket = "scpca-portal-cert-${var.user}-${var.stage}"
force_destroy = var.stage == "prod" ? false : true

tags = merge(
var.default_tags,
{
Name = "scpca-portal-cert-${var.user}-${var.stage}"
Environment = var.stage
}
)
}

resource "aws_s3_bucket_ownership_controls" "scpca_portal_cert_bucket" {
bucket = aws_s3_bucket.scpca_portal_cert_bucket.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_acl" "scpca_portal_cert_bucket" {
depends_on = [aws_s3_bucket_ownership_controls.scpca_portal_cert_bucket]
bucket = aws_s3_bucket.scpca_portal_cert_bucket.id
acl = "private"
}
force_destroy = var.stage == "prod" ? false : true

resource "aws_s3_bucket_lifecycle_configuration" "scpca_portal_cert_bucket" {
bucket = aws_s3_bucket.scpca_portal_cert_bucket.id
rule {
lifecycle_rule {
id = "auto-delete-after-30-days-${var.user}-${var.stage}"
status = "Enabled"
abort_incomplete_multipart_upload {
days_after_initiation = 1
}
prefix = ""
enabled = true
abort_incomplete_multipart_upload_days = 1

expiration {
days = 30
}
}

tags = merge(
var.default_tags,
{
Name = "scpca-portal-cert-${var.user}-${var.stage}"
Environment = var.stage
}
)
}

resource "aws_s3_bucket_public_access_block" "scpca_portal_cert_bucket" {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ variable "ssh_public_key" {
output "environment_variables" {
value = [
{name = "DATABASE_NAME"
value = aws_db_instance.postgres_db.db_name},
value = aws_db_instance.postgres_db.name},
{name = "DATABASE_HOST"
value = aws_db_instance.postgres_db.address},
{name = "DATABASE_USER"
Expand Down

0 comments on commit 1703f1f

Please sign in to comment.