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

Disable delete-protection for cognito user pool #993

Closed
wants to merge 22 commits into from

Conversation

suleman-sohail
Copy link
Contributor

@suleman-sohail suleman-sohail commented May 7, 2023

On nuking aws account, having cognito user pool, as one of its resources, nuke fails to cleanup. deletionProtection support is added in remove method of cognito-user-pool.

@suleman-sohail suleman-sohail requested a review from a team as a code owner May 7, 2023 11:24
Copy link

@farrukh-taqveem farrukh-taqveem left a comment

Choose a reason for hiding this comment

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

Let's remove these un-necessary lines & spaces.
Rest Looks good.

@@ -47,6 +47,7 @@ type DisableDeletionProtection struct {
CloudformationStack bool `yaml:"CloudformationStack"`
ELBv2 bool `yaml:"ELBv2"`
QLDBLedger bool `yaml:"QLDBLedger"`
CognitoUserPool bool `yaml:"CognitoUserPool"`

Choose a reason for hiding this comment

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

Suggested change
CognitoUserPool bool `yaml:"CognitoUserPool"`
CognitoUserPool bool `yaml:"CognitoUserPool"`

)

type CognitoUserPool struct {
svc *cognitoidentityprovider.CognitoIdentityProvider
name *string
id *string

Choose a reason for hiding this comment

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

Suggested change

return nil
}
}

Choose a reason for hiding this comment

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

Suggested change

@suleman-sohail suleman-sohail changed the title Added disable feature for cognito-user-pool deletion protection Disable delete-protection for cognito user pool May 8, 2023
@npellegrin
Copy link
Contributor

Hello. I am also looking forward to have this feature in aws-nuke. Does this Merge request require additional fixes I can help with ?

@npellegrin
Copy link
Contributor

npellegrin commented Jul 20, 2023

References #989

@suleman-sohail
Copy link
Contributor Author

Hello. I am also looking forward to have this feature in aws-nuke. Does this Merge request require additional fixes I can help with ?

Nope, I believe we are all set for the referenced issue, we can get this merged.

if err != nil {
if f.featureFlags.DisableDeletionProtection.CognitoUserPool{
err = f.DisableProtection()
if err!=nil{
Copy link
Member

Choose a reason for hiding this comment

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

Can you please quickly run go fmt on these files?

Comment on lines 11 to 14
svc *cognitoidentityprovider.CognitoIdentityProvider
name *string
id *string
featureFlags config.FeatureFlags
Copy link
Member

Choose a reason for hiding this comment

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

Formatting is still off here. You should setup your IDE to use gofmt to automatically format files on save.

}
userPool := userPoolOutput.UserPool
params := &cognitoidentityprovider.UpdateUserPoolInput{
DeletionProtection: &cognitoidentityprovider.DeletionProtectionType_Values()[1],
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
DeletionProtection: &cognitoidentityprovider.DeletionProtectionType_Values()[1],
DeletionProtection: aws.String(cognitoidentityprovider.DeletionProtectionTypeInactive),

Using the constant here instead of accessing an array by numbers

_, err := f.svc.DeleteUserPool(&cognitoidentityprovider.DeleteUserPoolInput{
UserPoolId: f.id,
})
if err != nil {
if f.featureFlags.DisableDeletionProtection.CognitoUserPool {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if f.featureFlags.DisableDeletionProtection.CognitoUserPool {
awsErr, ok := err.(awserr.Error)
if ok && strings.Contains(awsErr.Message(), "Deletion protection must be inactivated first") &&
f.featureFlags.DisableDeletionProtection.CognitoUserPool {

I'd prefer checking here if the error is actually caused by the Deletion Protection before proceeding

@der-eismann der-eismann added the status/waiting-reponse Waiting for the issue author to respond to a question. label Aug 29, 2023
@BrutalSimplicity
Copy link

Ran into this issue today. It looks like this is pending some updates from the author @suleman-sohail. If they're unable to get to this, should a new PR be opened? It doesn't look like much is left here but some cosmetic changes.

@suleman-sohail
Copy link
Contributor Author

Ran into this issue today. It looks like this is pending some updates from the author @suleman-sohail. If they're unable to get to this, should a new PR be opened? It doesn't look like much is left here but some cosmetic changes.

Hi, I could not reply anytime soon, thanks for waiting. I believe I was able to address the relevant comments, I might have miss something. You can create PR on child branch of this one, do any changes you think are needed for this PR to get merged, get that merged in this one, and we are good to go.

@ekristen
Copy link
Collaborator

This was implemented in the fork via this PR ekristen/aws-nuke#311 and is in 3.23.0 and forward.

If you have a chance, please check it out and let us know if you run into an issues by opening an issue over on the fork.


Please see the copy of the notice from the README about the deprecation of this project. Sven was kind enough to grant me access to help triage and close issues and pull requests that have already been addressed in the actively maintained fork. Some additional information is located in the welcome issue for more information.

Caution

This repository for aws-nuke is no longer being actively maintained. We recommend users to switch to the actively maintained fork of this project at ekristen/aws-nuke.
We appreciate all the support and contributions we've received throughout the life of this project. We believe that the fork will continue to provide the functionality and support that you have come to expect from aws-nuke.
Please note that this deprecation means we will not be addressing issues, accepting pull requests, or making future releases from this repository.
Thank you for your understanding and support.

@ekristen ekristen closed this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-reponse Waiting for the issue author to respond to a question.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants