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

feat: limit access to S3 by VPC ID #1829

Merged
merged 21 commits into from
May 23, 2024

Conversation

zucchinidev
Copy link
Contributor

@zucchinidev zucchinidev commented May 20, 2024

#187430076

Checklist:

  • Have you added Release Notes in the docs repositories?
  • Have you ran make run-integration-tests and make run-terraform-tests?
  • Have you ran acceptance tests for the service under change?
  • Have you followed the Conventional Commits specification?

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/187636617

The labels on this github issue will be updated when the story is started.

@zucchinidev zucchinidev force-pushed the feat_limit_access_to_s3_by_vpc_id_187430076 branch 2 times, most recently from d595ff2 to 4616c3f Compare May 21, 2024 11:27
Copy link
Member

@blgm blgm left a comment

Choose a reason for hiding this comment

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

The implementation of the feature is great. My main comment is that it would be really nice if the test could create the VPC endpoint that it needs. If a user needs to

  • create a VPC endpoint
  • set and environment variable
  • run the test
  • delete the VPC endpoint

Then this is just a barrier to running the tests. An automated test is by definition automated. Perhaps I'm missing something that makes this impossible.

aws-s3-bucket.yml Show resolved Hide resolved
@@ -74,6 +74,22 @@ data "aws_iam_policy_document" "user_policy" {
format("%s/*", var.arn)
]
}

dynamic "statement" {
for_each = var.allowed_aws_vpc_id != "" ? [1] : []
Copy link
Member

Choose a reason for hiding this comment

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

Is this better than using count which is commonly used in other *.tf files? I'm not asking for it to be changed, just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A dynamic block acts much like a for expression and the for_each argument provides the complex value to iterate over. This is a build-in expression that does not admit the count.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I missed that it was a dynamic.

acceptance-tests/helpers/s3vpcendpoint/main.go Outdated Show resolved Hide resolved
acceptance-tests/helpers/s3vpcendpoint/main.go Outdated Show resolved Hide resolved
@zucchinidev zucchinidev requested a review from blgm May 22, 2024 17:07
* create a VPC endpoint
* run the test
* delete the VPC endpoint

[#187430076](https://www.pivotaltracker.com/story/show/187430076)
@zucchinidev zucchinidev force-pushed the feat_limit_access_to_s3_by_vpc_id_187430076 branch from 2464bf0 to f7951c2 Compare May 22, 2024 17:07
@@ -2,7 +2,7 @@ package acceptance_tests_test

import (
"csbbrokerpakaws/acceptance-tests/helpers/apps"
"csbbrokerpakaws/acceptance-tests/helpers/dms"
"csbbrokerpakaws/acceptance-tests/helpers/awscli/dms"
Copy link
Member

Choose a reason for hiding this comment

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

I would have been inclined to leave the dms package as it was and just factor out one function into awscli, but I don't see any harm in moving it.

func CreateEndpoint(allowedVPCID, defaultRegion string) string {

// Get the ARN of the current user
getCallerIdentityCommand := []string{
Copy link
Member

Choose a reason for hiding this comment

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

Personally I prefer to inline these rather than have another variable (that you have to think of a name for), but this approach works too.

By("deleting the file from bucket using the app")
app.DELETE(filename)

By("verifying that the file no longer exists")
Copy link
Member

Choose a reason for hiding this comment

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

It feels to be that this is testing something else that's beyond the VPC endpoint access restriction, but I don't think it necessary to remove it.

@@ -74,6 +74,22 @@ data "aws_iam_policy_document" "user_policy" {
format("%s/*", var.arn)
]
}

dynamic "statement" {
for_each = var.allowed_aws_vpc_id != "" ? [1] : []
Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I missed that it was a dynamic.

@zucchinidev zucchinidev merged commit b099a19 into main May 23, 2024
8 checks passed
@zucchinidev zucchinidev deleted the feat_limit_access_to_s3_by_vpc_id_187430076 branch May 23, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants