Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created June 5, 2021 11:12
Show Gist options
  • Save dallasmarlow/822c0308a912f4dbad6d2eea768802c9 to your computer and use it in GitHub Desktop.
Save dallasmarlow/822c0308a912f4dbad6d2eea768802c9 to your computer and use it in GitHub Desktop.
S3 helm repo
data "aws_iam_policy_document" "helm_repo_bucket_policy" {
statement {
actions = [
"s3:*",
]
condition {
test = "NotIpAddress"
variable = "aws:SourceIp"
values = [
var.remote_network,
]
}
condition {
test = "StringNotEquals"
variable = "aws:sourceVpce"
values = [
data.terraform_remote_state.vpc.outputs.s3_endpoint_id,
]
}
effect = "Deny"
principals {
type = "AWS"
identifiers = [
"*",
]
}
resources = [
aws_s3_bucket.helm_repo.arn,
"${aws_s3_bucket.helm_repo.arn}/*",
]
}
}
resource "aws_s3_bucket" "helm_repo" {
bucket = var.helm_repo_domain
acl = "public-read"
force_destroy = true
website {
index_document = "index.yaml"
}
}
resource "aws_s3_bucket_policy" "helm_repo" {
bucket = aws_s3_bucket.helm_repo.id
policy = data.aws_iam_policy_document.helm_repo_bucket_policy.json
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment