Skip to content

fix: Use PublicSubnet from stack to run task#2024

Merged
mergify[bot] merged 13 commits intoaws:mainlinefrom
ota42y:feature/use_subnets_from_stack
Mar 10, 2021
Merged

fix: Use PublicSubnet from stack to run task#2024
mergify[bot] merged 13 commits intoaws:mainlinefrom
ota42y:feature/use_subnets_from_stack

Conversation

@ota42y
Copy link
Copy Markdown
Contributor

@ota42y ota42y commented Mar 6, 2021

Please read this Issue.
#2022

There was a structure called EnvironmentVPC that was not being used, so we added data to it and returned it when describing the Stack.
We also used this information to get PublicSubnet when executing the Task.

We can get SecurityGroup from the Stack, but we have not changed it because it is not relevant to this change.

@ota42y ota42y requested a review from a team as a code owner March 6, 2021 03:04
@ota42y ota42y requested a review from bvtujo March 6, 2021 03:04
@ota42y ota42y changed the title Use PublicSubnet from stack to run task Bug Fixes: Use PublicSubnet from stack to run task Mar 6, 2021
@ota42y ota42y changed the title Bug Fixes: Use PublicSubnet from stack to run task fix: Use PublicSubnet from stack to run task Mar 6, 2021
@ota42y ota42y force-pushed the feature/use_subnets_from_stack branch from 30d50f5 to 60edf43 Compare March 6, 2021 03:13
Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

Hello ota42y! Thank you so much for reporting and fixing the issue 🙇‍♀️ Really appreciated! I have some small suggestions below.

Comment thread internal/pkg/cli/task_run.go Outdated
Comment thread internal/pkg/describe/env.go Outdated
Comment thread internal/pkg/describe/env.go Outdated
Comment thread internal/pkg/task/env_runner.go Outdated
Comment thread internal/pkg/cli/task_run.go Outdated
ota42y and others added 7 commits March 9, 2021 18:51
Co-authored-by: Wanxian Yang <79273084+Lou1415926@users.noreply.github.com>
Co-authored-by: Wanxian Yang <79273084+Lou1415926@users.noreply.github.com>
Co-authored-by: Wanxian Yang <79273084+Lou1415926@users.noreply.github.com>
Co-authored-by: Wanxian Yang <79273084+Lou1415926@users.noreply.github.com>
@ota42y
Copy link
Copy Markdown
Contributor Author

ota42y commented Mar 9, 2021

I have completed the fix!

Copy link
Copy Markdown
Contributor

@bvtujo bvtujo left a comment

Choose a reason for hiding this comment

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

Thank you so much for this change, this will be super helpful. A few comments, nothing major :)

Comment thread internal/pkg/cli/task_run.go Outdated
Comment thread internal/pkg/describe/env.go Outdated
return tags, nil

for _, out := range envStack.Outputs {
if out.OutputKey != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use the aws.StringValue() function here to do this comparison? We tend to prefer it to explicit pointer dereference in this codebase. It could be coupled with a switch here as well:

for _, out := range envStack.Outputs {
    switch aws.StringValue(out.OutputKey) {
    case stack.EnvOutputVPCID:
        environmentVPC.ID = aws.StringValue(out.OutputValue)
    ...
    }
}

We already import it into the describe package in other files, so it isn't adding a dependency, and it can avoid the extra conditional.

Comment thread internal/pkg/describe/env_test.go Outdated
Environment: testEnv,
Services: envSvcs,
Tags: map[string]string{"copilot-application": "testApp", "copilot-environment": "testEnv"},
EnvironmentVPC: &EnvironmentVPC{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙏 thank you so much for these tests!

}
if len(subnets) == 0 {
if description == nil || description.EnvironmentVPC == nil || len(description.EnvironmentVPC.PublicSubnetIDs) == 0 {
return nil, errNoSubnetFound
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use a more descriptive error here, since this is wrapping multiple failure modes? Perhaps we could break it out into separate descriptive errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we don't need to check description.
Because when description is nil, we'll get error and return above line.

And I don't use pointer for description.EnvironmentVPC .
Because when we can't get data from Stack, we return error so we can set this struct always.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Got it! Thanks for the follow up!

ota42y and others added 2 commits March 10, 2021 11:54
@ota42y ota42y force-pushed the feature/use_subnets_from_stack branch 3 times, most recently from 3ef4c6b to 0377970 Compare March 10, 2021 04:15
When we can't get Stack we'll get error, so this struct always exist.
@ota42y
Copy link
Copy Markdown
Contributor Author

ota42y commented Mar 10, 2021

I have completed the fix!

Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

Thank you so much for the quick turnaround!!

@bvtujo
Copy link
Copy Markdown
Contributor

bvtujo commented Mar 10, 2021

Thank you so much for this, @ota42y! A super helpful enhancement.

@mergify mergify Bot merged commit 394cc1b into aws:mainline Mar 10, 2021
mergify Bot pushed a commit that referenced this pull request Mar 10, 2021
This PR is a quick follow up on #2024.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
@ota42y ota42y deleted the feature/use_subnets_from_stack branch March 11, 2021 04:50
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
Please read this Issue.
aws#2022

There was a structure called EnvironmentVPC that was not being used, so we added data to it and returned it when describing the Stack.
We also used this information to get PublicSubnet when executing the Task.

We can get SecurityGroup from the Stack, but we have not changed it because it is not relevant to this change.
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
This PR is a quick follow up on aws#2024.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
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.

4 participants