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

Refactor nuking default resources code. #673

Merged
merged 3 commits into from
Apr 16, 2024
Merged

Conversation

james03160927
Copy link
Contributor

Description

Partially Fixing #651
TODO: make sure to use default on all EC2 resources.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.
  • Attention Grunts - if this PR adds support for a new resource, ensure the nuke_sandbox and nuke_phxdevops jobs in .circleci/config.yml have been updated with appropriate exclusions (either directly in the job or via the .circleci/nuke_config.yml file) to prevent nuking IAM roles, groups, resources, etc that are important for the test accounts.

Release Notes (draft)

Added / Removed / Updated [X].

Migration Guide

@james03160927 james03160927 changed the title new approach to nuke default resources [WIP] new approach to nuke default resources Apr 5, 2024
@james03160927 james03160927 force-pushed the 34/nuking-default-vpc branch from 45f2761 to acd7a11 Compare April 12, 2024 22:08
@james03160927 james03160927 changed the title [WIP] new approach to nuke default resources Refactor nuking default resources code. Apr 12, 2024
func (v *EC2VPCs) getAll(c context.Context, configObj config.Config) ([]*string, error) {
func (v *EC2VPCs) getAll(_ context.Context, configObj config.Config) ([]*string, error) {
// Note: This filter initially handles non-default resources and can be overridden by passing the only-default filter to choose default VPCs.
var isdefault = "false"
Copy link
Member

Choose a reason for hiding this comment

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

make sense to use boolean variables? if left as string, in the future(during refactoring maybe) someone may try to put different value than true/false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @denis256, this is the value we pass in as part of the DescribeVpcs endpoint.
We use boolean inside the configObj for this. Essentailly you need to set either true or false as a string. That's how the API is defined.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I was thinking of representing value before passing it to AWS, and don't allow invalid value to be set in:

var isdefault := false
...
Values: awsgo.StringSlice([]string{fmt.Sprintf("%v", isdefault})
...
...

isdefault can take only valid values, and will be transformed in string when passed to AWS

@james03160927 james03160927 merged commit 483056f into master Apr 16, 2024
2 of 3 checks passed
@james03160927 james03160927 deleted the 34/nuking-default-vpc branch April 16, 2024 20:30
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.

2 participants