forked from zbmowrey/cloud-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeployment-to-main.tf
More file actions
39 lines (36 loc) · 1.15 KB
/
deployment-to-main.tf
File metadata and controls
39 lines (36 loc) · 1.15 KB
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
provider "aws" {
alias = "main"
region = var.region
default_tags {
tags = local.default_tags
}
assume_role {
role_arn = "arn:aws:iam::${var.main_account_id}:role/OrganizationAccountAccessRole"
}
}
resource "aws_iam_role" "main-allow-deployment" {
provider = aws.main
name = "ApplicationDeployment"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = "sts:AssumeRole",
Principal = { "AWS" : "arn:aws:iam::${var.deployment_account_id}:root" }
}
]
})
}
resource "aws_iam_policy" "main-deployment-permissions" {
provider = aws.main
name = "ApplicationDeployment"
description = "Permissions necessary for deployment of infrastructure into Develop Account."
policy = file("deployment-policy.json")
}
resource "aws_iam_policy_attachment" "main-deployment-permissions" {
provider = aws.main
name = "Allowed Infrastructure Deployment"
roles = [aws_iam_role.main-allow-deployment.name]
policy_arn = aws_iam_policy.main-deployment-permissions.arn
}