Skip to content

Commit 27dfe4d

Browse files
authored
Merge pull request #34 from Aswin-Vijayan/TEC-56
Add s3 and dynamodb table provisioning code
2 parents 9e81140 + 29d7d45 commit 27dfe4d

File tree

15 files changed

+143
-98
lines changed

15 files changed

+143
-98
lines changed

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ terraform init \
1111
-backend-config="key=dev/vpc.tfstate" \
1212
-backend-config="bucket=dcube-terraform-state" \
1313
-backend-config="region=us-west-2" \
14-
-backend-config="dynamodb_table=terraform-state-lock"
15-
```
16-
```
17-
18-
terraform destroy \
19-
-backend-config="key=dev/vpc.tfstate" \
20-
-backend-config="bucket=dcube-terraform-state" \
21-
-backend-config="region=us-west-2" \
22-
-backend-config="dynamodb_table=terraform-state-lock"
14+
-backend-config="dynamodb_table=terraform-state-lock" \
15+
-var-file=../../../vars/dev/vpc.tfvars
2316
```
2417

2518
#### VPC Provisioning

environments/dev/alb-asg/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ module "alb" {
6262
health_check_protocol = var.health_check_protocol
6363
health_check_interval = var.health_check_interval
6464
health_check_timeout = var.health_check_timeout
65-
health_check_healthy_treshold = var.health_check_healthy_treshold
66-
health_check_unhealthy_treshold = var.health_check_unhealthy_treshold
65+
health_check_healthy_threshold = var.health_check_healthy_threshold
66+
health_check_unhealthy_threshold= var.health_check_unhealthy_threshold
6767
listener_port = var.listener_port
6868
listener_protocol = var.listener_protocol
6969
listener_type = var.listener_type

environments/dev/alb-asg/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ variable "health_check_timeout" {
6969
type = number
7070
}
7171

72-
variable "health_check_healthy_treshold" {
72+
variable "health_check_healthy_threshold" {
7373
description = "Health check healthy threshold"
7474
type = number
7575
}
7676

77-
variable "health_check_unhealthy_treshold" {
77+
variable "health_check_unhealthy_threshold" {
7878
description = "Health check unhealthy threshold"
7979
type = number
8080
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
resource "aws_dynamodb_table" "state_lock_table" {
2+
name = "${var.environment}-${var.application}-dynamodb-table"
3+
billing_mode = var.billing_mode
4+
hash_key = var.hash_key
5+
6+
attribute {
7+
name = var.attribute_name
8+
type = var.attribute_type
9+
}
10+
11+
tags = merge(
12+
{
13+
Name = "${var.environment}-${var.application}-dynamodb-table"
14+
Environment = var.environment,
15+
Owner = var.owner,
16+
CostCenter = var.cost_center,
17+
Application = var.application
18+
},
19+
var.tags
20+
)
21+
}

environments/dev/backend/s3.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
provider "aws" {
2+
region = "us-west-2"
3+
}
4+
5+
resource "aws_s3_bucket" "state_lock_bucket" {
6+
bucket = "${var.environment}-${var.application}-s3-bucket"
7+
8+
tags = merge(
9+
{
10+
Name = "${var.environment}-${var.application}-s3-bucket"
11+
Environment = var.environment,
12+
Owner = var.owner,
13+
CostCenter = var.cost_center,
14+
Application = var.application
15+
},
16+
var.tags
17+
)
18+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
variable "tags" {
2+
default = {}
3+
type = map(string)
4+
description = "Extra tags to attach to the alb-asg resources"
5+
}
6+
7+
variable "region" {
8+
type = string
9+
description = "Region of the alb-asg"
10+
}
11+
12+
variable "billing_mode" {
13+
type = string
14+
description = "Billing mode for dynamodb"
15+
}
16+
17+
variable "hash_key" {
18+
type = string
19+
description = "Hash key name of dynamodb"
20+
}
21+
22+
variable "attribute_name" {
23+
type = string
24+
description = "Attribute name of dynamodb"
25+
}
26+
27+
variable "attribute_type" {
28+
type = string
29+
description = "Attribute type of dynamodb"
30+
}
31+
32+
variable "owner" {
33+
type = string
34+
description = "Name of owner"
35+
}
36+
37+
variable "environment" {
38+
type = string
39+
description = "The environment name for the resources."
40+
}
41+
42+
variable "cost_center" {
43+
type = string
44+
description = "Name of cost-center for the resources."
45+
}
46+
47+
variable "application" {
48+
type = string
49+
description = "Name of the application"
50+
}
51+

environments/dev/tag-policy/main.tf

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ module "tag-policy" {
99
policy_type = var.policy_type
1010
target_id = var.target_id
1111

12-
name_tag_key = var.name_tag_key
13-
name_enforce_for_values = var.name_enforce_for_values
14-
15-
environment_tag_key = var.environment_tag_key
16-
environment_enforce_for_values = var.environment_enforce_for_values
17-
18-
owner_tag_key = var.owner_tag_key
19-
owner_tag_value = var.owner_tag_value
20-
owner_enforce_for_values = var.owner_enforce_for_values
21-
22-
costcenter_tag_key = var.costcenter_tag_key
23-
costcenter_tag_value = var.costcenter_tag_value
24-
costcenter_enforce_for_values = var.costcenter_enforce_for_values
25-
26-
application_tag_key = var.application_tag_key
27-
application_enforce_for_values = var.application_enforce_for_values
12+
name_tag_key = var.name_tag_key
13+
environment_tag_key = var.environment_tag_key
14+
owner_tag_key = var.owner_tag_key
15+
owner_tag_value = var.owner_tag_value
16+
costcenter_tag_key = var.costcenter_tag_key
17+
costcenter_tag_value = var.costcenter_tag_value
18+
application_tag_key = var.application_tag_key
19+
enforce_for_values = var.enforce_for_values
2820
}

environments/dev/tag-policy/variables.tf

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,11 @@ variable "name_tag_key" {
2323
description = "The tag key for the 'Name' tag."
2424
}
2525

26-
variable "name_enforce_for_values" {
27-
type = list(string)
28-
description = "A list of tag values to enforce for the 'Name' tag."
29-
}
30-
3126
variable "environment_tag_key" {
3227
type = string
3328
description = "The tag key for the 'Environment' tag."
3429
}
3530

36-
variable "environment_enforce_for_values" {
37-
type = list(string)
38-
description = "A list of tag values to enforce for the 'Environment' tag."
39-
}
40-
4131
variable "owner_tag_key" {
4232
type = string
4333
description = "The tag key for the 'Owner' tag."
@@ -48,11 +38,6 @@ variable "owner_tag_value" {
4838
description = "A list of valid tag values for the 'Owner' tag."
4939
}
5040

51-
variable "owner_enforce_for_values" {
52-
type = list(string)
53-
description = "A list of tag values to enforce for the 'Owner' tag."
54-
}
55-
5641
variable "costcenter_tag_key" {
5742
type = string
5843
description = "The tag key for the 'CostCenter' tag."
@@ -63,17 +48,12 @@ variable "costcenter_tag_value" {
6348
description = "A list of valid tag values for the 'CostCenter' tag."
6449
}
6550

66-
variable "costcenter_enforce_for_values" {
67-
type = list(string)
68-
description = "A list of tag values to enforce for the 'CostCenter' tag."
69-
}
70-
7151
variable "application_tag_key" {
7252
type = string
7353
description = "The tag key for the 'Application' tag."
7454
}
7555

76-
variable "application_enforce_for_values" {
56+
variable "enforce_for_values" {
7757
type = list(string)
7858
description = "A list of tag values to enforce for the 'Application' tag."
7959
}

modules/alb/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ resource "aws_alb_target_group" "alb_tg" {
3131
protocol = var.health_check_protocol
3232
interval = var.health_check_interval
3333
timeout = var.health_check_timeout
34-
healthy_threshold = var.health_check_healthy_treshold
35-
unhealthy_threshold = var.health_check_unhealthy_treshold
34+
healthy_threshold = var.health_check_healthy_threshold
35+
unhealthy_threshold = var.health_check_unhealthy_threshold
3636
}
3737

3838
load_balancing_algorithm_type = var.load_balancing_algorithm

modules/alb/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ variable "health_check_timeout" {
7979
type = number
8080
}
8181

82-
variable "health_check_healthy_treshold" {
82+
variable "health_check_healthy_threshold" {
8383
description = "Health check healthy threshold"
8484
type = number
8585
}
8686

87-
variable "health_check_unhealthy_treshold" {
87+
variable "health_check_unhealthy_threshold" {
8888
description = "Health check unhealthy threshold"
8989
type = number
9090
}

0 commit comments

Comments
 (0)