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 S3 bucket policies to lock down unsecure access #236

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

jpl-btlunsfo
Copy link
Collaborator

Purpose

  • Adds s3 bucket policy to block unsecure access on the various S3 buckets created by the unity-sps terraform

Proposed Changes

  • ADD aws_s3_bucket_policy entries for the 4 buckets that are created (one in terraform-unity-sps-airflow, three in terraform-unity-sps-initiators)

Issues

Testing

  • Tested in personal deployment; deployed without issues...
  • Unsure of how to test the initiators buckets.

Copy link
Collaborator

@LucaCinquini LucaCinquini left a comment

Choose a reason for hiding this comment

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

Hi @jpl-btlunsfo : the changes to the code look ok, but can you try to run some DAGs to make sure they still work?

@jpl-btlunsfo
Copy link
Collaborator Author

@LucaCinquini no issues running the cwl dag as a test, and while my attempted run of the sbg step by step dag failed I don't think that was related to this- the airflow-related S3 bucket is for the airflow logs, and the (failed) logs are present/were uploaded without issue.

Copy link
Collaborator

@LucaCinquini LucaCinquini left a comment

Choose a reason for hiding this comment

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

@jpl-btlunsfo : I am getting this error when deploying Airflow with this branch. Deployment of EKS and Karpenter were successfull:

module.unity-sps-ogc-processes-api.kubernetes_deployment.ogc_processes_api: Still creating... [3m20s elapsed]
module.unity-sps-ogc-processes-api.kubernetes_deployment.ogc_processes_api: Still creating... [3m30s elapsed]
module.unity-sps-ogc-processes-api.kubernetes_deployment.ogc_processes_api: Creation complete after 3m38s [id=sps/ogc-processes-api]

│ Error: creating S3 Bucket (unity-luca-1-dev-sps-airflowlogs): operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: P863FADYWY73YADB, HostID: A1gMq0R27T/Xuxefmmw4qTqzyeDXTzLWsUJw7Ee1yYrywbolP9ZFgtje/+hjz44s07Z3jWs69DY=, api error TooManyBuckets: You have attempted to create more buckets than allowed

│ with module.unity-sps-airflow.aws_s3_bucket.airflow_logs,
│ on modules/terraform-unity-sps-airflow/main.tf line 117, in resource "aws_s3_bucket" "airflow_logs":
│ 117: resource "aws_s3_bucket" "airflow_logs" {



│ Error: creating S3 Bucket (unity-luca-1-dev-sps-config): operation error S3: CreateBucket, https response error StatusCode: 400, RequestID: AD9RZ779H94SBQQ7, HostID: bGJYw353obYeM82RX6DK/vVDuAJLUOlgUiYuKzMpIr20LMcOVQRQsG+hKtT/1mprRtgTtzst0RM=, api error TooManyBuckets: You have attempted to create more buckets than allowed

│ with module.unity-sps-initiators.aws_s3_bucket.config,
│ on modules/terraform-unity-sps-initiators/main.tf line 21, in resource "aws_s3_bucket" "config":
│ 21: resource "aws_s3_bucket" "config" {

@jpl-btlunsfo
Copy link
Collaborator Author

TooManyBuckets: You have attempted to create more buckets than allowed

I don't believe that's due to the S3 bucket policy change- that looks like we've made too many buckets. Maybe @galenatjpl has seen this before?

@LucaCinquini
Copy link
Collaborator

I don't have that problem if I use the code in develop, though...

@LucaCinquini
Copy link
Collaborator

I don't have that problem if I use the code in develop, though. I will try again later.

@galenatjpl
Copy link
Collaborator

@jpl-btlunsfo @LucaCinquini , yes it appears we are hitting a limit. I'm cleaning up some buckets now

Copy link
Collaborator

@LucaCinquini LucaCinquini left a comment

Choose a reason for hiding this comment

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

@jpl-btlunsfo : the deployment with this branch works for me if this line:

bucket = format(local.resource_name_prefix, each.value)

is changed from "each.value" to "each.key"

@jpl-btlunsfo
Copy link
Collaborator Author

Ah, yeah it looks like I'd left that format in when it wasn't necessary. I've reworked that resource a bit, since it doesn't really need key/values in that for_each, and retested. Could you give it a retest too @LucaCinquini ?

Copy link
Collaborator

@LucaCinquini LucaCinquini left a comment

Choose a reason for hiding this comment

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

After the latest changes, the deployment worked for me, please go ahead and merge into develop.

@jpl-btlunsfo jpl-btlunsfo merged commit 5039748 into develop Nov 18, 2024
2 checks passed
@jpl-btlunsfo jpl-btlunsfo deleted the 231-lockdown-buckets branch November 18, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants