Skip to content

Commit 059c0c5

Browse files
darendosterman
authored andcommitted
Enable encryption and do not request a specific role (#3)
* Do not specify read/write target roles hashicorp/terraform-provider-aws#2844 [ch9409] * Enable encryption * Add variable for encryption flag
1 parent 95653fc commit 059c0c5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ resource "aws_dynamodb_table" "default" {
1717
hash_key = "${var.hash_key}"
1818
range_key = "${var.range_key}"
1919

20+
server_side_encryption {
21+
enabled = "${var.enable_encryption}"
22+
}
23+
2024
lifecycle {
2125
ignore_changes = ["read_capacity", "write_capacity"]
2226
}
@@ -105,15 +109,10 @@ resource "aws_iam_role_policy" "autoscaler_cloudwatch" {
105109
policy = "${data.aws_iam_policy_document.autoscaler_cloudwatch.json}"
106110
}
107111

108-
data "aws_iam_role" "autoscale_service" {
109-
name = "AWSServiceRoleForApplicationAutoScaling_DynamoDBTable"
110-
}
111-
112112
resource "aws_appautoscaling_target" "read_target" {
113113
max_capacity = "${var.autoscale_max_read_capacity}"
114114
min_capacity = "${var.autoscale_min_read_capacity}"
115115
resource_id = "table/${module.default.id}"
116-
role_arn = "${data.aws_iam_role.autoscale_service.arn}"
117116
scalable_dimension = "dynamodb:table:ReadCapacityUnits"
118117
service_namespace = "dynamodb"
119118
}
@@ -138,7 +137,6 @@ resource "aws_appautoscaling_target" "write_target" {
138137
max_capacity = "${var.autoscale_max_write_capacity}"
139138
min_capacity = "${var.autoscale_min_write_capacity}"
140139
resource_id = "table/${module.default.id}"
141-
role_arn = "${data.aws_iam_role.autoscale_service.arn}"
142140
scalable_dimension = "dynamodb:table:WriteCapacityUnits"
143141
service_namespace = "dynamodb"
144142
}

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ variable "stage" {
1010
type = "string"
1111
}
1212

13+
variable "enable_encryption" {
14+
default = "true"
15+
}
16+
1317
variable "attributes" {
1418
type = "list"
1519
default = []

0 commit comments

Comments
 (0)