Skip to content

Needs to remove roles before instances #15

@spacemonkey

Description

@spacemonkey

The command looks good, and seems to be configured and running as expected, but looks like the process to remove roles needs to happen before removing instances that have those roles assigned.

I will include full output at the bottom.

This is:

  • Bug

Expected Behavior

Expected this to delete all AWS resources provisioned by Webiny

Actual Behavior

Ran successfully until deleting lambdas, threw an error (below).

Steps to Reproduce the Problem

  1. Deploy webiny environment
  2. Wish there was an easier way to upgrade stock environments to newer versions of Webiny
  3. Run npx remove-aws-resources and select everything that is not my one ec2 instance! :-)

Possible Solution

Looks like a role is still assigned to a lambda, so maybe the API call to fetch a list of roles is incomplete?

ALTERNATE: Maybe identify known roles that should not be deleted but are listed (maybe with an asterisk or something like "system role, do not remove") so users do not assume those were created by webiny. For example, the only serverless anything on my account is from webiny, so I ASSUME that it is okay to remove the admin role as I do not use it for anything else on my account... If that is what threw this error and is not a webiny role, identifying that up front would be super helpful.

Error Output

npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  ✔ Fetched 11 Lambda functions!
  ✔ Fetched 0 API Gateways!
  ✔ Fetched 7 CloudFront distributions!
  ✔ Fetched 5 IAM roles!
  ✔ Fetched 18 Log Groups!
  ✔ Fetched 21 S3 buckets!
? Select resources to delete arn:aws:cloudfront::206569707808:distribution/E1W55M8UG7AA0K, arn:aws:cloudfront::206569707808:distribution/E293SS644K462C, arn:aws:cloudfront::206569707808:distribution/E3M6Y04CCEVD3I, arn:aws:cloudfront::20656970780
8:distribution/E2AHFFE1FC5KBJ, arn:aws:cloudfront::206569707808:distribution/EZH3IO1B00HTF, arn:aws:cloudfront::206569707808:distribution/EEFJ1TSVXOM5R, arn:aws:cloudfront::206569707808:distribution/E1QZ3ODBBB4FNN, arn:aws:logs:us-east-1:20656970
7808:log-group:/aws/lambda/fm-image-transformer-c18e807:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/fm-download-69212cf:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/headless-cms-1f383ab:*, arn:aws:logs:us-east-1:2
06569707808:log-group:/aws/lambda/dynamo-to-elastic-6e6567d:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/ps-render-dc1ab5d:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/graphql-f56aef5:*, arn:aws:logs:us-east-1:2065
69707808:log-group:/aws/lambda/ps-queue-add-11ca0e8:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/pb-update-settings-0b65b57:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/ps-queue-process-249970a:*, arn:aws:logs:us-e
ast-1:206569707808:log-group:/aws/lambda/fm-image-transformer-fbf182c:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/fm-download-3ae5ea7:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/headless-cms-16ee4f5:*, arn:aws:lo
gs:us-east-1:206569707808:log-group:/aws/lambda/ps-render-299922c:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/ps-queue-add-bddef20:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/dynamo-to-elastic-c8c9eac:*, arn:aws:
logs:us-east-1:206569707808:log-group:/aws/lambda/graphql-9d69fe9:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/pb-update-settings-179c3b0:*, arn:aws:logs:us-east-1:206569707808:log-group:/aws/lambda/ps-queue-process-86f49b5:*, app
-5695c92, delivery-b232674, admin-app-6250fb0, fm-bucket-beabbc9, app-8b23ce5, delivery-90b9eae, admin-app-e8e0a6a, arn:aws:iam::206569707808:role/default-lambda-role-2eeb136, arn:aws:iam::206569707808:role/headless-cms-lambda-role-df3bfd5, arn:a
ws:iam::206569707808:role/api-lambda-role-41702b4, arn:aws:iam::206569707808:role/fm-lambda-role-008408b, arn:aws:iam::206569707808:role/admin, arn:aws:lambda:us-east-1:206569707808:function:graphql-f56aef5, arn:aws:lambda:us-east-1:206569707808:
function:headless-cms-1f383ab, arn:aws:lambda:us-east-1:206569707808:function:dynamo-to-elastic-6e6567d, arn:aws:lambda:us-east-1:206569707808:function:ps-queue-process-249970a, arn:aws:lambda:us-east-1:206569707808:function:ps-queue-add-11ca0e8,
 arn:aws:lambda:us-east-1:206569707808:function:ps-render-dc1ab5d, arn:aws:lambda:us-east-1:206569707808:function:pb-update-settings-0b65b57, arn:aws:lambda:us-east-1:206569707808:function:fm-download-69212cf, arn:aws:lambda:us-east-1:20656970780
8:function:ps-flush-83dd7b2, arn:aws:lambda:us-east-1:206569707808:function:fm-manage-8185dd4, arn:aws:lambda:us-east-1:206569707808:function:fm-image-transformer-c18e807
  ⠏ Delete 7 CloudFront distribution
    → Disabling d5rbatpii5mc6.cloudfront.net...
  ✔ Delete 18 CloudWatch Log Groups
  ⠏ Delete 7 buckets
    → Emptying admin-app-6250fb0...
  ⠏ Delete 5 IAM roles
    → Deleting admin...
  ⠏ Delete 11 Lambda functions
    → Deleting fm-manage-8185dd4...
/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/protocol/query.js:50
    resp.error = util.error(new Error(), {
                            ^

DeleteConflict: Cannot delete entity, must remove roles from instance profile first.
    at Request.extractError (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/protocol/query.js:50:29)
    at Request.callListeners (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/request.js:690:12)
    at Request.callListeners (/Users/spacemonkey/.npm/_npx/e71c66f909670347/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
  code: 'DeleteConflict',
  time: 2021-05-31T17:57:12.068Z,
  requestId: '58b7fb2d-d43f-4521-88ec-c274d15af690',
  statusCode: 409,
  retryable: false,
  retryDelay: 19.43912990527279
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions