forked from ministryofjustice/cloud-platform-terraform-sqs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
53 lines (45 loc) · 1.61 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
resource "random_id" "id" {
byte_length = 6
}
resource "aws_sqs_queue" "terraform_queue" {
name = "${var.team_name}-${var.environment-name}-sqs-${random_id.id.hex}"
visibility_timeout_seconds = "${var.visibility_timeout_seconds}"
message_retention_seconds = "${var.message_retention_seconds}"
max_message_size = "${var.max_message_size}"
delay_seconds = "${var.delay_seconds}"
receive_wait_time_seconds = "${var.receive_wait_time_seconds}"
kms_master_key_id = "${var.kms_master_key_id}"
kms_data_key_reuse_period_seconds = "${var.kms_data_key_reuse_period_seconds}"
tags {
business-unit = "${var.business-unit}"
application = "${var.application}"
is-production = "${var.is-production}"
environment-name = "${var.environment-name}"
owner = "${var.team_name}"
infrastructure-support = "${var.infrastructure-support}"
}
}
resource "aws_iam_user" "user" {
name = "cp-sqs-${random_id.id.hex}"
path = "/system/sqs-user/${var.team_name}/"
}
resource "aws_iam_access_key" "key" {
user = "${aws_iam_user.user.name}"
}
resource "aws_iam_user_policy" "userpol" {
name = "${aws_iam_user.user.name}"
policy = "${data.aws_iam_policy_document.policy.json}"
user = "${aws_iam_user.user.name}"
}
data "aws_iam_policy_document" "policy" {
statement {
actions = [
"sqs:*",
]
resources = [
"${aws_sqs_queue.terraform_queue.arn}",
]
}
}