Skip to content

Commit

Permalink
Add Open Data Pvnet (#713)
Browse files Browse the repository at this point in the history
* Add Open Data Pvnet

* remove env

* remove tag

* update

* groups
  • Loading branch information
peterdudfield authored Dec 9, 2024
1 parent 17ddf20 commit 9425a67
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions terraform/modules/storage/open-data-pvnet-s3/bucket.tf
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"
}
}
39 changes: 39 additions & 0 deletions terraform/modules/storage/open-data-pvnet-s3/iam.tf
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]
}
7 changes: 7 additions & 0 deletions terraform/nowcasting/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The componentes ares:
6.3 - PVSite ML bucket
6.4 - PVSite Forecast
6.5 - PVSite Database Clean Up
7.1 - Open Data PVnet
Variables used across all modules
======*/
Expand Down Expand Up @@ -918,3 +919,9 @@ module "pvsite_database_clean_up" {
]
container-command = []
}


# 7.1 Open Data PVnet - Public s3 bucket
module "open_data_pvnet_s3" {
source = "../../modules/storage/open-data-pvnet-s3"
}

0 comments on commit 9425a67

Please sign in to comment.