Skip to content

Commit 5233fa8

Browse files
committed
CCM-6250: amp module
1 parent 2481572 commit 5233fa8

8 files changed

Lines changed: 167 additions & 4 deletions

File tree

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is for you! Please, updated to the versions agreed by your team.
22

3-
terraform 1.9.1
3+
terraform 1.9.2
44
pre-commit 3.6.0
55
nodejs 18.18.2
66
gitleaks 8.18.4
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "aws_amplify_branch" "main" {
2+
app_id = var.amplify_app_id
3+
description = var.description
4+
branch_name = var.branch
5+
display_name = var.name
6+
enable_pull_request_preview = var.enable_pull_request_preview
7+
enable_auto_build = var.enable_auto_build
8+
stage = var.stage
9+
framework = var.framework
10+
11+
environment_variables = var.environment_variables
12+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
locals {
2+
csi = format(
3+
"%s-%s-%s-%s-%s",
4+
var.project,
5+
var.environment,
6+
var.component,
7+
var.module,
8+
var.name,
9+
)
10+
11+
# CSI for use in resources with an account namespace, eg IAM roles
12+
csi_account = replace(
13+
format(
14+
"%s-%s-%s-%s-%s-%s",
15+
var.project,
16+
var.region,
17+
var.environment,
18+
var.component,
19+
var.module,
20+
var.name,
21+
),
22+
"_",
23+
"",
24+
)
25+
26+
default_tags = merge(
27+
var.default_tags,
28+
{
29+
Module = var.module
30+
Name = local.csi
31+
},
32+
)
33+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "name" {
2+
value = aws_amplify_branch.main.branch_name
3+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
##
2+
# Basic inherited variables for terraformscaffold modules
3+
##
4+
5+
variable "project" {
6+
type = string
7+
description = "The name of the terraformscaffold project calling the module"
8+
}
9+
10+
variable "environment" {
11+
type = string
12+
description = "The name of the terraformscaffold environment the module is called for"
13+
}
14+
15+
variable "component" {
16+
type = string
17+
description = "The name of the terraformscaffold component calling this module"
18+
}
19+
20+
variable "aws_account_id" {
21+
type = string
22+
description = "The AWS Account ID (numeric)"
23+
}
24+
25+
variable "group" {
26+
type = string
27+
description = "The group variables are being inherited from (often synonmous with account short-name)"
28+
}
29+
30+
variable "description" {
31+
type = string
32+
description = "Description for the branch"
33+
}
34+
35+
##
36+
# Module self-identification
37+
##
38+
39+
variable "module" {
40+
type = string
41+
description = "The name of this module. This is a special variable, it should be set only here and never overridden."
42+
default = "kms"
43+
}
44+
45+
##
46+
# Variable specific to the module
47+
##
48+
49+
# We presume this will always be specified. The default of {} will cause an error if a valid map is not specified.
50+
# If we ever want to define this but allow it to not be specified, then we must provide a default tag keypair will be applied
51+
# as the true default. In any other case default_tags should be removed from the module.
52+
variable "default_tags" {
53+
type = map(string)
54+
description = "Default tag map for application to all taggable resources in the module"
55+
default = {}
56+
}
57+
58+
variable "region" {
59+
type = string
60+
description = "The AWS Region"
61+
}
62+
63+
variable "name" {
64+
type = string
65+
description = "A unique name to distinguish this module invocation from others within the same CSI scope"
66+
}
67+
68+
variable "amplify_app_id" {
69+
type = string
70+
description = "Amplify application ID"
71+
}
72+
73+
variable "branch" {
74+
description = "The name of the branch being deployed"
75+
type = string
76+
}
77+
78+
variable "enable_auto_build" {
79+
type = bool
80+
description = "Enable the auto build of the branch code as well as just the resources for it"
81+
default = false
82+
}
83+
84+
variable "enable_pull_request_preview" {
85+
type = bool
86+
description = "Enable the pull request preview"
87+
default = false
88+
}
89+
90+
variable "stage" {
91+
type = string
92+
default = null
93+
description = "Determine what stage is being deployed for"
94+
}
95+
96+
variable "framework" {
97+
type = string
98+
default = null
99+
description = "Set what framework to use"
100+
}
101+
102+
variable "environment_variables" {
103+
type = map(string)
104+
default = {}
105+
description = "Environment variables to be used for amplify branch"
106+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
terraform {
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
}
7+
}
8+
required_version = ">= 1.9.0"
9+
}

infrastructure/modules/lambda/data_archive_file_lambda.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
data "archive_file" "lambda" {
2-
type = "zip"
3-
source_dir = "${path.module}/${var.function_code_base_path}/${var.function_code_dir}"
2+
type = "zip"
3+
source_dir = "${path.module}/${var.function_code_base_path}/${var.function_code_dir}"
44

55
# Timestamp in path to resolve https://github.com/hashicorp/terraform-provider-archive/issues/39
66
output_path = "${path.module}/archives/${local.csi}_${timestamp()}.zip"

infrastructure/modules/s3bucket/s3_bucket_acl.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_s3_bucket_acl" "main" {
2-
count = var.object_ownership == "BucketOwnerEnforced" ? 0 : 1
2+
count = var.object_ownership == "BucketOwnerEnforced" ? 0 : 1
33

44
bucket = aws_s3_bucket.main.id
55
acl = var.acl

0 commit comments

Comments
 (0)