forked from Capgemini/terraform-amazon-ecs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
48 lines (41 loc) · 1.36 KB
/
iam.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
/* registry user, access key and policies */
resource "aws_iam_user" "registry" {
name = "${var.registry_username}"
}
resource "aws_iam_access_key" "registry" {
user = "${aws_iam_user.registry.name}"
}
resource "aws_iam_policy" "registry" {
name = "registryaccess"
policy = "${template_file.registry_policy.rendered}"
}
resource "aws_iam_policy_attachment" "registry-attach" {
name = "registry-attachment"
users = ["${aws_iam_user.registry.name}"]
policy_arn = "${aws_iam_policy.registry.arn}"
}
/* ecs iam role and policies */
resource "aws_iam_role" "ecs_role" {
name = "ecs_role"
assume_role_policy = "${file("policies/ecs-role.json")}"
}
/* ecs service scheduler role */
resource "aws_iam_role_policy" "ecs_service_role_policy" {
name = "ecs_service_role_policy"
policy = "${template_file.ecs_service_role_policy.rendered}"
role = "${aws_iam_role.ecs_role.id}"
}
/* ec2 container instance role & policy */
resource "aws_iam_role_policy" "ecs_instance_role_policy" {
name = "ecs_instance_role_policy"
policy = "${file("policies/ecs-instance-role-policy.json")}"
role = "${aws_iam_role.ecs_role.id}"
}
/**
* IAM profile to be used in auto-scaling launch configuration.
*/
resource "aws_iam_instance_profile" "ecs" {
name = "ecs-instance-profile"
path = "/"
roles = ["${aws_iam_role.ecs_role.name}"]
}