Skip to content

Commit

Permalink
[services][terraform] Move current config to dev/
Browse files Browse the repository at this point in the history
Summary:
Currently our terraform is designed to set up localstack. This diff splits the config into dev/ and remote/ directories, and moves the current config into dev/. This is so we can add remote/ and set up a remote AWS account.
Shared resources (DDB tables and S3 buckets) are held in `modules/shared/` directory as a terraform module.

Also updated the AWS terraform provider - the old one was outdated

Test Plan:
Set up localstack and make sure it was populated by terraform
```
cd services && yarn reset-local-cloud
awslocal dynamodb list-tables
```

Reviewers: jon, varun, michal

Reviewed By: jon

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D8567
  • Loading branch information
barthap committed Jul 21, 2023
1 parent b4f53d4 commit 62a3e67
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 76 deletions.
2 changes: 1 addition & 1 deletion services/scripts/init_local_cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# docker-compose up -d --force-recreate localstack
docker-compose up -d localstack

pushd terraform
pushd terraform/dev

./run.sh

Expand Down
23 changes: 0 additions & 23 deletions services/terraform/.terraform.lock.hcl

This file was deleted.

File renamed without changes.
25 changes: 25 additions & 0 deletions services/terraform/dev/.terraform.lock.hcl

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

39 changes: 39 additions & 0 deletions services/terraform/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
locals {
aws_settings = ({
region = "us-east-2"
access_key = "fake"
secret_key = "fake"

skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
s3_use_path_style = true

override_endpoint = "http://localhost:4566"
})
}

provider "aws" {
region = local.aws_settings.region
access_key = local.aws_settings.access_key
secret_key = local.aws_settings.secret_key

skip_credentials_validation = local.aws_settings.skip_credentials_validation
skip_metadata_api_check = local.aws_settings.skip_metadata_api_check
skip_requesting_account_id = local.aws_settings.skip_requesting_account_id
s3_use_path_style = local.aws_settings.s3_use_path_style

dynamic "endpoints" {
for_each = local.aws_settings.override_endpoint[*]
content {
dynamodb = endpoints.value
s3 = endpoints.value
}
}
}

# Shared resources between local dev environment and remote AWS
module "shared" {
source = "../modules/shared"
}

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.9.0"
version = "~> 5.7.0"
}
}
}
File renamed without changes.
51 changes: 0 additions & 51 deletions services/terraform/main.tf

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions services/terraform/modules/shared/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.7.0"
}
}
}
File renamed without changes.

0 comments on commit 62a3e67

Please sign in to comment.