-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Open Data Pvnet * remove env * remove tag * update * groups
- Loading branch information
1 parent
17ddf20
commit 9425a67
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Public S3 bucket | ||
|
||
# Bucket itself | ||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket | ||
resource "aws_s3_bucket" "bucket" { | ||
bucket = "ocf-open-data-pvnet" | ||
|
||
tags = { | ||
Name = "Open_Data_PVNet" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Make IAM policy to write to the s3-public bucket | ||
|
||
data "aws_iam_policy_document" "open_data_pvnet_write_policy_description" { | ||
version = "2012-10-17" | ||
statement { | ||
actions = [ | ||
"s3:ListBucket", | ||
"s3:GetObject", | ||
"s3:PutObject", | ||
"s3:DeleteObject" | ||
] | ||
resources = [aws_s3_bucket.bucket.arn, "${aws_s3_bucket.bucket.arn}/*"] | ||
effect = "Allow" | ||
} | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy | ||
resource "aws_iam_policy" "open_data_pvnet_write_policy" { | ||
name = "s3-open_data_pvnet_write_policy" | ||
description = "Policy to write to bucket: ${aws_s3_bucket.bucket.bucket}" | ||
|
||
# Terraform's "jsonencode" function converts a | ||
# Terraform expression result to valid JSON syntax. | ||
policy = data.aws_iam_policy_document.open_data_pvnet_write_policy_description.json | ||
|
||
} | ||
|
||
|
||
# resource group | ||
resource "aws_iam_group" "open_data_pvnet_write_group" { | ||
name = "open_data_pvnet_write_group" | ||
} | ||
|
||
# attach policy to group | ||
resource "aws_iam_policy_attachment" "open_data_pvnet_write_policy_attachment" { | ||
name = "s3-write-attachment" | ||
policy_arn = aws_iam_policy.open_data_pvnet_write_policy.arn | ||
groups = [aws_iam_group.open_data_pvnet_write_group.name] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters