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

Block public access to S3 bucket as per standard compliance rules #581

Merged
merged 3 commits into from
May 3, 2023
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
2 changes: 1 addition & 1 deletion controllers/etcdcopybackupstask/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ var _ = Describe("EtcdCopyBackupsTaskController", func() {
Expect(*hostPathVolumeSource.Type).To(Equal(corev1.HostPathDirectory))
})

It("should create the correct volumes when store.SecretRef is not refered", func() {
It("should create the correct volumes when store.SecretRef is not referred", func() {
Expect(fakeClient.Create(ctx, secret)).To(Succeed())

store.SecretRef = &corev1.SecretReference{Name: secret.Name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
ENDPOINT_URL=""
if [[ -n "${LOCALSTACK_HOST}" ]]; then
ENDPOINT_URL=" --endpoint-url=http://${LOCALSTACK_HOST}"

fi

function setup_aws() {
Expand Down Expand Up @@ -49,7 +48,13 @@ function create_s3_bucket() {
result=$(aws ${ENDPOINT_URL} s3api get-bucket-location --bucket ${TEST_ID} 2>&1 || true)
if [[ $result == *NoSuchBucket* ]]; then
echo "Creating S3 bucket ${TEST_ID} in region ${AWS_REGION}"
aws ${ENDPOINT_URL} s3api create-bucket --bucket ${TEST_ID} --region ${AWS_REGION} --create-bucket-configuration LocationConstraint=${AWS_REGION}
aws ${ENDPOINT_URL} s3api create-bucket --bucket ${TEST_ID} --region ${AWS_REGION} --create-bucket-configuration LocationConstraint=${AWS_REGION} --acl private
# Block public access to the S3 bucket
aws ${ENDPOINT_URL} s3api put-public-access-block --bucket ${TEST_ID} --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"
# Deny non-HTTPS requests to the S3 bucket, except for localstack which is exposed on an HTTP endpoint
if [[ -z "${LOCALSTACK_HOST}" ]]; then
aws ${ENDPOINT_URL} s3api put-bucket-policy --bucket ${TEST_ID} --policy "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":[\"arn:aws:s3:::${TEST_ID}\",\"arn:aws:s3:::${TEST_ID}/*\"],\"Condition\":{\"Bool\":{\"aws:SecureTransport\":\"false\"},\"NumericLessThan\":{\"s3:TlsVersion\":\"1.2\"}}}]}"
fi
else
echo $result
if [[ $result != *${AWS_REGION}* ]]; then
Expand Down
2 changes: 1 addition & 1 deletion pkg/health/condition/check_backup_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type backupReadyCheck struct {
}

const (
// BackupSucceeded is a constant that means that etcd backup has been sucessfully taken
// BackupSucceeded is a constant that means that etcd backup has been successfully taken
BackupSucceeded string = "BackupSucceeded"
// BackupFailed is a constant that means that etcd backup has failed
BackupFailed string = "BackupFailed"
Expand Down