-
Notifications
You must be signed in to change notification settings - Fork 0
/
IAM.tf
37 lines (35 loc) · 969 Bytes
/
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
#BitcoinEC2 to S3 Policy
#Create Role
resource "aws_iam_role" "bitcoinec2_role" {
name = "bitcoinec2_role"
assume_role_policy = "${file("jsons/iam_role_assume_ec.json")}"
}
# Create S3 Bucket Policy
resource "aws_iam_policy" "ec2tos3btc" {
name = "ec2tos3btc"
description = "Give Access to BTC S3 Buckets"
#policy = "${file("IAM_policys_access_s3.json")}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::${var.bucket}"
}
]
}
EOF
# Assigne the Policy to Role.
}
resource "aws_iam_policy_attachment" "s3_to_ec2_attachment" {
name = "test-attachment"
roles = ["${aws_iam_role.bitcoinec2_role.name}"]
policy_arn = "${aws_iam_policy.ec2tos3btc.arn}"
}
#
resource "aws_iam_instance_profile" "bitcoinec2_profile" {
name = "bitcoinec2_profile"
role = "${aws_iam_role.bitcoinec2_role.name}"
}