Created
May 17, 2019 15:42
-
-
Save tndavaloz/bcd023a812731cb9da15c429e3aac14e to your computer and use it in GitHub Desktop.
Dax Reviews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role" "dax-reviews-role" { | |
name = "dax-reviews-cache" | |
assume_role_policy = "${data.aws_iam_policy_document.dax_role_policy_doc.json}" | |
} | |
data "aws_iam_policy_document" "dax_role_policy_doc" { | |
statement { | |
actions = [ | |
"sts:AssumeRole", | |
] | |
principals { | |
type = "Service" | |
identifiers = ["dax.amazonaws.com"] | |
} | |
} | |
} | |
data "aws_iam_policy_document" "dax-reviews-policy-document" { | |
statement { | |
effect = "Allow" | |
actions = [ | |
"dynamodb:BatchGetItem", | |
"dynamodb:GetItem", | |
"dynamodb:Query", | |
"dynamodb:Scan", | |
"dynamodb:BatchWriteItem", | |
"dynamodb:DeleteItem", | |
"dynamodb:PutItem", | |
"dynamodb:UpdateItem", | |
"dynamodb:DescribeLimits", | |
"dynamodb:DescribeTimeToLive", | |
"dynamodb:DescribeTable", | |
"dynamodb:ListTables", | |
] | |
resources = [ | |
"${aws_dynamodb_table.dynamodb_table.arn}*", | |
] | |
} | |
} | |
resource "aws_iam_policy" "dax-reviews-policy" { | |
name = "dax_reviews_policy" | |
description = "A policy for dax reviews" | |
policy = "${data.aws_iam_policy_document.dax-reviews-policy-document.json}" | |
} | |
resource "aws_iam_role_policy_attachment" "dax-reviews-attach" { | |
role = "${aws_iam_role.dax-reviews-role.name}" | |
policy_arn = "${aws_iam_policy.dax-reviews-policy.arn}" | |
} | |
resource "aws_dax_subnet_group" "dax_subnet" { | |
name = "dax-subnet" | |
subnet_ids = ["${local.private_subnets}"] | |
} | |
resource "aws_dax_cluster" "dax_review_cache" { | |
depends_on = ["aws_dax_subnet_group.dax_subnet"] | |
cluster_name = "reviews-dax-cache" | |
iam_role_arn = "${aws_iam_role.dax-reviews-role.arn}" | |
node_type = "dax.t2.medium" | |
replication_factor = 3 | |
subnet_group_name = "${aws_dax_subnet_group.dax_subnet.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment