Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k views
in Technique[技术] by (71.8m points)

amazon iam - Serverless on WSL2 Debian when deploying, Resource's path part only allows

Using WSL2 with Debian, I'm doing a sample project as detailed here, and I'm currently at this stage.

When I try to deploy, it gives me

An error occurred: ApiGatewayResourceNotesId - Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end. (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException;

It seems to be coming from my YAML line here (Error #1)

  environment:
    tableName: notes-sample

  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Scan
        - dynamodb:Query
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
        - dynamodb:DescribeTable
      Resource: "arn:aws:dynamodb:us-west-2:*:*" # <-- here ---

Yet the example shown on the website uses the same format as above, and I assume it works for them.

I've also tried formatting it this way (Error #2)

  environment:
    tableName: { "Ref": "notes-sample" } # <-- here: change 1 ---
  # 'iamRoleStatements' defines the permission policy for the Lambda function.
  # In this case Lambda functions are granted with permissions to access DynamoDB.
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Scan
        - dynamodb:Query
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
        - dynamodb:DescribeTable
      Resource: { "Fn::GetAtt": ["sample-note", "Arn"] } # <-- here: change 2 ---

however, when Serverless validates the template, it gives me the error

Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [notes-sample] in the Resources block of the template
      at /home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13

For one, I can't find that folder on my PC, and don't know where else it might be, and two the problem still seems to be this one line of code, and I don't know what I'm missing, here.

I've looked at examples one, two, and tried to go through this Japanese site, but I don't seem to be seeing what's wrong with this line.

I appreciate anyone's help.


Full error #1

An error occurred: ApiGatewayResourceNotesId - Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end. (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: f*******-4ae8-4**0-a822-7***********; Proxy: null).

Full error #2

Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [notes-sample] in the Resources block of the template
      at /home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13
      at tryCatcher (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:725:18)
      at _drainQueueStep (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/home/USER/.nvm/versions/node/v15.6.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (node:internal/timers:463:21)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...