mirror of
https://github.com/farcasclaudiu/terraform-course.git
synced 2026-06-22 07:01:56 +03:00
5d9eeb6c4c
* Terraform 0.12
49 lines
943 B
Terraform
49 lines
943 B
Terraform
resource "aws_iam_role" "s3-mybucket-role" {
|
|
name = "s3-mybucket-role"
|
|
assume_role_policy = <<EOF
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Action": "sts:AssumeRole",
|
|
"Principal": {
|
|
"Service": "ec2.amazonaws.com"
|
|
},
|
|
"Effect": "Allow",
|
|
"Sid": ""
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
}
|
|
|
|
resource "aws_iam_instance_profile" "s3-mybucket-role-instanceprofile" {
|
|
name = "s3-mybucket-role"
|
|
role = aws_iam_role.s3-mybucket-role.name
|
|
}
|
|
|
|
resource "aws_iam_role_policy" "s3-mybucket-role-policy" {
|
|
name = "s3-mybucket-role-policy"
|
|
role = aws_iam_role.s3-mybucket-role.id
|
|
policy = <<EOF
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Effect": "Allow",
|
|
"Action": [
|
|
"s3:*"
|
|
],
|
|
"Resource": [
|
|
"arn:aws:s3:::mybucket-c29df1",
|
|
"arn:aws:s3:::mybucket-c29df1/*"
|
|
]
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
}
|
|
|