mmajis / plantuml-serverless

Serverless PlantUML diagram rendering
GNU General Public License v3.0
48 stars 22 forks source link

Problem with deploying on AWS #18

Closed circlesmiler closed 2 years ago

circlesmiler commented 3 years ago

Hello,

I have problems with deploying the lambdas in my AWS. I did following steps:

  1. Install aws cli
  2. Install serverless cli
  3. Install docker
  4. Set AWS credentials on profile "core" in file ~/.aws/credentials
  5. Run npm install
  6. Run mvn clean package
  7. Create a public API with AWS API Gateway
  8. Run sls deploy --stage plantuml

Seems to work fine until this error appears:

Serverless: Invoke aws:package:finalize
Serverless: Invoke aws:common:moveArtifactsToPackage
Serverless: Invoke aws:common:validate
Serverless Domain Manager: NotFoundException: Invalid domain name identifier specified

 Error ---------------------------------------------------

  Error: Error: **not-for-public**.eu-west-1.amazonaws.com not found.
      at ServerlessCustomDomain.<anonymous> (/Users/limbus/repository/plantuml-serverless/node_modules/serverless-domain-manager/dist/index.js:311:27)
      at Generator.throw (<anonymous>)
      at rejected (/Users/limbus/repository/plantuml-serverless/node_modules/serverless-domain-manager/dist/index.js:5:65)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              16.4.0
     Framework Version:         2.46.0 (local)
     Plugin Version:            5.3.0
     SDK Version:               4.2.3
     Components Version:        3.12.0

I changed following parts in the serverless.yml (only domain/plantuml and certificateName):

custom:
  domains:
    plantuml: "**not-for-public**.eu-west-1.amazonaws.com"
  customDomain:
    certificateName: "*.execute-api.eu-west-1.amazonaws.com"

I do not understand, why the domain and certificate is needed here... anyway... can you help?

Reason for trying to update: The (older) version in the serverless repo (https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:293246570391:applications~plantuml-render) seems not to be working with Java 8 (Corretto). I tried to change the environment of the lambda functions manually to Java 8 (Corretto). That did not work.

circlesmiler commented 3 years ago

Ok, I think that I now understand, that there is an additional setup on AWS needed to have a public domain for the lambdas. But now, as I have one (so... I already had one, but I didn't used it), it still have the same error... I try to dive deeper into the serverless-domain-manager plugin, as this seems to be the problem here.

I successfully could deploy the lambdas, when I removed the serverless-domain-manager plugin from the serverless.yml.

mmajis commented 3 years ago

Hi!

It would be good to make the custom domain setup optional for the serverless framework deployment. I'll look into that at some point. I also noticed that the profile: core is something that is out of place generally and will remove it, thanks for noting that!

If you do want a custom domain, see here for instructions (e.g. running sls create_domain after config is in place): https://www.serverless.com/blog/serverless-api-gateway-domain

Without a custom domain I would venture a guess that it should work if you remove the serverless-domain-manager plugin and start from scratch e.g. first run sls remove and then sls deploy again.

Another option is to deploy with SAM as that deployment config doesn't contain a custom domain.

circlesmiler commented 3 years ago

Ok... I solved it.

Things I found out:

To be honest, at first, I was a little bit frustrated about this, but at the end, I really want a defined domain for my service, because if I want to re-deploy, I don't want to have a new domain. (This domain is part of a lot of IDE configurations etc.)

Maybe it would be nice to have a link to the blog post in the README.md.

I also tried to blow up the serverless.yml a little bit for my needs. Maybe you can use something of this:

custom:
  stage: ${opt:stage, self:provider.stage}
  domains:
    prod: 
      url: plantuml.***.net
      certArn: 'arn:aws:acm:eu-west-1:***'
    dev: 
      url: plantuml-dev.***.net
      certArn: 'arn:aws:acm:eu-west-1:***'
  customDomain:
    domainName: ${self:custom.domains.${self:custom.stage}.url}
    certificateArn : ${self:custom.domains.${self:custom.stage}.certArn}
    basePath: ''
    stage: "${self:custom.stage}"
    createRoute53Record: true
    # 'regional' is used, because we do not use CloudFoundation
    # If you want to use CloudFront, the certificate must be created in region 'us-east-1'
    endpointType: regional
  apigwBinary:
    types:
      - '*/*'
mmajis commented 2 years ago

I updated the deployment instructions at some point during the summer. Closing this, but please let me know if something is still unclear. Thanks!