Skip to content

Commit

Permalink
2023 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
darkpandarts committed Oct 1, 2023
1 parent 2f8d123 commit 2a5a20b
Show file tree
Hide file tree
Showing 56 changed files with 144 additions and 586 deletions.
4 changes: 2 additions & 2 deletions serverless/exif-ripper/00_test_upload_image_2_s3_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ cp -v test_images/OG_IMG_20220423_124829.jpg test_images/sls_test_img1.jpg
SOURCE_BUCKET=$(aws --profile $AWS_PROFILE \
--region eu-west-1 \
ssm get-parameter \
--name /genomics/exifripper/dev/bucketsource \
--name /stablecaps/exifripper/dev/bucketsource \
| jq '.Parameter.Value' \
| sed 's|"||g')

### Get destination bucket name
DEST_BUCKET=$(aws --profile $AWS_PROFILE \
--region eu-west-1 \
ssm get-parameter \
--name /genomics/exifripper/dev/bucketdest \
--name /stablecaps/exifripper/dev/bucketdest \
| jq '.Parameter.Value' \
| sed 's|"||g')

Expand Down
2 changes: 1 addition & 1 deletion serverless/exif-ripper/config/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ aws_region: eu-west-1
deployment_bucket: serverless-deployment-holder-658fi8r7
stage: dev
iam_role_arn: arn:aws:iam::779934699932:role/lambda/dev/exif-ripper-dev-eu-west-1-lambdaRole20220427180337074400000001
ssm_root_prefix: /genomics/exifripper
ssm_root_prefix: /stablecaps/exifripper
2 changes: 1 addition & 1 deletion serverless/exif-ripper/config/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ aws_region: eu-west-1
deployment_bucket: serverless-deployment-holder-658fi8r7
stage: prod
iam_role_arn: arn:aws:iam::779934699932:role/lambda/dev/exif-ripper-dev-eu-west-1-lambdaRole20220427180337074400000001
ssm_root_prefix: /genomics/exifripper
ssm_root_prefix: /stablecaps/exifripper
2 changes: 1 addition & 1 deletion terraform_v1/01_sls_deployment_bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ No resources.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_env"></a> [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"dev"` | no |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create uniuque s3 resources | `string` | n/a | yes |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes |

## Outputs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
locals {
tags = {
environment = var.env
project = "genomics"
owner = "gtampi/devops"
created_by = "terraform"
}

bucket_name = "serverless-deployment-holder-${var.env}-${var.random_string}"
}

module "s3_serverless_deployment_bucket" {

source = "terraform-aws-modules/s3-bucket/aws"
Expand Down
2 changes: 0 additions & 2 deletions terraform_v1/01_sls_deployment_bucket/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ terraform {
provider "aws" {
region = "eu-west-1"
}

# TODO: Setup remote state
2 changes: 1 addition & 1 deletion terraform_v1/01_sls_deployment_bucket/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ variable "env" {
}

variable "random_string" {
description = "A random string to ensure that different people can create uniuque s3 resources"
description = "A random string to ensure that different people can create globally unique s3 resources"
type = string
}
10 changes: 10 additions & 0 deletions terraform_v1/01_sls_deployment_bucket/vlocals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
locals {
tags = {
environment = var.env
project = "stablecaps"
owner = "DevOps"
created_by = "terraform"
}

bucket_name = "serverless-deployment-holder-${var.env}-${var.random_string}"
}
4 changes: 2 additions & 2 deletions terraform_v1/02_DEV/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ No resources.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_env"></a> [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"dev"` | no |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create uniuque s3 resources | `string` | n/a | yes |
| <a name="input_ssm_root_prefix"></a> [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/genomics/exifripper"` | no |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes |
| <a name="input_ssm_root_prefix"></a> [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/stablecaps/exifripper"` | no |

## Outputs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
locals {
tags = {
environment = var.env
project = "genomics"
owner = "gtampi/devops"
created_by = "terraform"
}
}

module "exif_buckets" {
source = "../modules/exif_ripper_buckets"

env = var.env
random_string = var.random_string
bucket_source = "genomics-source"
bucket_dest = "genomics-destination"
bucket_source = "stablecaps-source"
bucket_dest = "stablecaps-destination"

tags = local.tags

Expand Down
1 change: 0 additions & 1 deletion terraform_v1/02_DEV/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ provider "aws" {
region = "eu-west-1"
}

# TODO: Setup remote state
4 changes: 2 additions & 2 deletions terraform_v1/02_DEV/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ variable "env" {
}

variable "random_string" {
description = "A random string to ensure that different people can create uniuque s3 resources"
description = "A random string to ensure that different people can create globally unique s3 resources"
type = string
}

variable "ssm_root_prefix" {
description = "SSM root prefix used to construct the key path"
type = string
default = "/genomics/exifripper"
default = "/stablecaps/exifripper"
}
8 changes: 8 additions & 0 deletions terraform_v1/02_DEV/vlocals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
tags = {
environment = var.env
project = "stablecaps"
owner = "DevOps"
created_by = "terraform"
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions terraform_v1/03_PROD/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ No resources.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_env"></a> [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"prod"` | no |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create uniuque s3 resources | `string` | n/a | yes |
| <a name="input_ssm_root_prefix"></a> [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/genomics/exifripper"` | no |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes |
| <a name="input_ssm_root_prefix"></a> [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/stablecaps/exifripper"` | no |

## Outputs

Expand Down
25 changes: 25 additions & 0 deletions terraform_v1/03_PROD/ini_setup_prod.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module "exif_buckets" {
source = "../modules/exif_ripper_buckets"

env = var.env
random_string = var.random_string
bucket_source = "stablecaps-source"
bucket_dest = "stablecaps-destination"

tags = local.tags

ssm_root_prefix = var.ssm_root_prefix

}

module "lambda_role_and_policies" {
source = "../modules/lambda_iam_role_and_policies"

env = var.env
bucket_source = module.exif_buckets.bucket_source_name
bucket_dest = module.exif_buckets.bucket_dest_name

tags = local.tags

ssm_root_prefix = var.ssm_root_prefix
}
40 changes: 0 additions & 40 deletions terraform_v1/03_PROD/outputs.tf

This file was deleted.

1 change: 0 additions & 1 deletion terraform_v1/03_PROD/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ provider "aws" {
region = "eu-west-1"
}

# TODO: Setup remote state
48 changes: 0 additions & 48 deletions terraform_v1/03_PROD/setup_prod.tf

This file was deleted.

4 changes: 2 additions & 2 deletions terraform_v1/03_PROD/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ variable "env" {
}

variable "random_string" {
description = "A random string to ensure that different people can create uniuque s3 resources"
description = "A random string to ensure that different people can create globally unique s3 resources"
type = string
}

variable "ssm_root_prefix" {
description = "SSM root prefix used to construct the key path"
type = string
default = "/genomics/exifripper"
default = "/stablecaps/exifripper"
}
8 changes: 8 additions & 0 deletions terraform_v1/03_PROD/vlocals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
tags = {
environment = var.env
project = "stablecaps"
owner = "DevOps"
created_by = "terraform"
}
}
16 changes: 16 additions & 0 deletions terraform_v1/03_PROD/voutputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
output "iam_role_arn" {
description = "Lambda IAM role arn used for serverless function"
value = module.lambda_role_and_policies.iam_role_arn
}

output "bucket_source_name" {
description = "exif-ripper s3 source bucket name"
value = module.exif_buckets.bucket_source_name
}

output "bucket_dest_name" {
description = "exif-ripper s3 destination bucket name"
value = module.exif_buckets.bucket_dest_name
}

# NOTE: users module disabled for purposes of this example
2 changes: 1 addition & 1 deletion terraform_v1/modules/exif_ripper_buckets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ No requirements.
| <a name="input_bucket_dest"></a> [bucket\_dest](#input\_bucket\_dest) | Exif-ripper destination bucket that sanitised files are copied to | `string` | n/a | yes |
| <a name="input_bucket_source"></a> [bucket\_source](#input\_bucket\_source) | Exif-ripper source bucket that is monitored for new files | `string` | n/a | yes |
| <a name="input_env"></a> [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | n/a | yes |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create uniuque s3 resources | `string` | n/a | yes |
| <a name="input_random_string"></a> [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes |
| <a name="input_ssm_root_prefix"></a> [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | A map that is used to apply tags to resources created by terraform | `map(string)` | n/a | yes |

Expand Down
4 changes: 2 additions & 2 deletions terraform_v1/modules/exif_ripper_buckets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "env" {
}

variable "random_string" {
description = "A random string to ensure that different people can create uniuque s3 resources"
description = "A random string to ensure that different people can create globally unique s3 resources"
type = string
}

Expand All @@ -27,4 +27,4 @@ variable "ssm_root_prefix" {
variable "tags" {
description = "A map that is used to apply tags to resources created by terraform"
type = map(string)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
locals {
lambda_role_name = "exif-ripper-${var.env}-eu-west-1-lambdaRole"
}

resource "aws_iam_role" "lambda_role" {
name_prefix = local.lambda_role_name

Expand Down
3 changes: 3 additions & 0 deletions terraform_v1/modules/lambda_iam_role_and_policies/vlocals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
lambda_role_name = "exif-ripper-${var.env}-eu-west-1-lambdaRole"
}
4 changes: 2 additions & 2 deletions terraform_v2/00_setup_remote_s3_backend_dev/dev.backend.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
region = "eu-west-1"
bucket = "tf-backend-dev-genomics-bhuna"
dynamodb_table = "tf-backend-dev-genomics-bhuna"
bucket = "tf-backend-dev-stablecaps-bhuna"
dynamodb_table = "tf-backend-dev-stablecaps-bhuna"
Loading

0 comments on commit 2a5a20b

Please sign in to comment.