Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding k8s-infra-kops-scale-tests bucket with public read #5696

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions infra/aws/terraform/s3/k8s-infra-e2e-boskos-scale-001/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Local .terraform directories
**/.terraform/*

Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkprzekwas suggestion: we should probably move this .gitignore file to ../infra/aws/terraform so all the sub-repos inherit this config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can think about having some generic ignore at the top level of the terraform directory. But that should be a dedicated PR that would also remove other ignores.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. let's do that in a separate PR.

# .tfstate files
*.tfstate
*.tfstate.*
*.tfplan

# Crash log files
crash.log

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Ignore CLI configuration files
.terraformrc
terraform.rc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions infra/aws/terraform/s3/k8s-infra-e2e-boskos-scale-001/bucket.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

resource "aws_s3_bucket" "k8s_infra_kops_scale_tests" {
bucket = "k8s-infra-kops-scale-tests"
}

resource "aws_s3_bucket_public_access_block" "k8s_infra_kops_scale_tests" {
bucket = aws_s3_bucket.k8s_infra_kops_scale_tests.id

block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}

resource "aws_s3_bucket_policy" "k8s_infra_kops_scale_tests" {
bucket = aws_s3_bucket.k8s_infra_kops_scale_tests.id

depends_on = [aws_s3_bucket_public_access_block.k8s_infra_kops_scale_tests]

policy = jsonencode({
"Id" : "Public-Access",
"Version" : "2012-10-17",
"Statement" : [
{
"Action" : "s3:ListBucket",
"Effect" : "Allow",
"Resource" : "${aws_s3_bucket.k8s_infra_kops_scale_tests.arn}",
"Principal" : "*"
},
{
"Action" : "s3:GetObject",
"Effect" : "Allow",
"Resource" : "${aws_s3_bucket.k8s_infra_kops_scale_tests.arn}/*",
"Principal" : "*"
},
{
"Sid" : "RequireTLSForObjectAccess",
"Action" : "s3:*",
"Effect" : "Deny",
"Resource" : "${aws_s3_bucket.k8s_infra_kops_scale_tests.arn}/*",
"Condition" : {
"Bool" : {
"aws:SecureTransport" : "false"
}
},
"Principal" : "*"
}
]
})
}
33 changes: 33 additions & 0 deletions infra/aws/terraform/s3/k8s-infra-e2e-boskos-scale-001/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2023 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

terraform {
backend "s3" {
bucket = "k8s-infra-kops-scale-tests-tf-state"
region = "us-east-2"
key = "s3/k8s-infra-kops-scale-tests/terraform.tfstate"
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}

provider "aws" {
region = "us-east-2"
}