serverless-domain-manager icon indicating copy to clipboard operation
serverless-domain-manager copied to clipboard

Does not seem to work with Java-based projects

Open NMichas opened this issue 7 years ago • 4 comments

Just tried the plugin with the default project layout created by sls create --template aws-java-maven and it does not seem to work:

  • ACM cert was properly created (manually).
  • create_domain successfully manages to create the entry in both Route 53 and API Gateway, where I also manually confirmed ACM cert was properly bound after 20' or so.
  • deploy produces:
Serverless: Packaging service...
  Error --------------------------------------------------
  Error: Could not set up basepath mapping. Try running sls create_domain first.
Error: Cannot find AWS::ApiGateway::Deployment

Trying to debug a little further, the problem seems to be in getDeploymentId where it iterates over the keys of compiledCloudFormationTemplate.Resources looking for AWS::ApiGateway::Deployment (and it can't find any). Some extra debug output in getDeploymentId:

console.log("cloudTemplate=", cloudTemplate);
console.log("cloudTemplate keys=", Object.keys(cloudTemplate.Resources));

=>

cloudTemplate= { AWSTemplateFormatVersion: '2010-09-09',
  Description: 'The AWS CloudFormation template for this Serverless application',
  Resources:
   { ServerlessDeploymentBucket: { Type: 'AWS::S3::Bucket', Properties: [Object] },
     HelloLogGroup: { Type: 'AWS::Logs::LogGroup', Properties: [Object] },
     IamRoleLambdaExecution: { Type: 'AWS::IAM::Role', Properties: [Object] },
     HelloLambdaFunction:
      { Type: 'AWS::Lambda::Function',
        Properties: [Object],
        DependsOn: [Object] } },
  Outputs: { ServerlessDeploymentBucketName: { Value: [Object] } } }

cloudTemplate keys= [ 'ServerlessDeploymentBucket',
  'HelloLogGroup',
  'IamRoleLambdaExecution',
  'HelloLambdaFunction' ]

Is this a known issue or I am doing something wrong here?

NMichas avatar Jan 21 '18 10:01 NMichas

@NMichas

I didn't run into this issue when I tried to setup serverless-domain-manager after running sls create --template aws-java-maven. Could you confirm that you are on the latest version of the plugin, and possibly provide your serverless.yml?

jconstance-amplify avatar Jan 26 '18 15:01 jconstance-amplify

Hi, I reproduced it on a newly created project with sls create --template aws-java-maven. Here's my versions info:

sls --version
1.25.0
more node_modules/serverless-domain-manager/package.json | grep -i version
"version": "2.2.2"
node --version
v8.9.4
npm --version
5.6.0

And here's my serverless.yml:

service: aws-java-maven 

plugins:
  - serverless-domain-manager

custom:
  stage: ${opt:stage, 'test'}
  domains:
      test: test.REDACTED.REDACTED
  customDomain:
    basePath: ''
    domainName: ${self:custom.domains.${self:custom.stage}}
    stage: ${self:custom.stage}
    createRoute53Record: true

provider:
  name: aws
  runtime: java8
  stage: ${opt:stage, 'test'}
  region: ${opt:region, 'us-east-1'}

package:
  artifact: target/hello-dev.jar

functions:
  hello:
    handler: com.serverless.Handler

Deployment takes place via sls --aws-profile REDACTED -s test deploy.

NMichas avatar Jan 26 '18 20:01 NMichas

I'm seeing the same behavior but we aren't using the template.

ssuh@MSC-CGY2R32LT:/mnt/c/Users/ysuh/cox_auto/vin-level-views$ serverless delete_domain --stage nonprod
Serverless: Domain was deleted.
ssuh@MSC-CGY2R32LT:/mnt/c/Users/ysuh/cox_auto/vin-level-views$ serverless create_domain --stage nonprod
Serverless: 'igniteapitest.awsdataservnp.manheim.com' was created/updated. New domains may take up to 40 minutes to be initialized.
ssuh@MSC-CGY2R32LT:/mnt/c/Users/ysuh/cox_auto/vin-level-views$ serverless deploy --stage nonprod --force
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...

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

  Error: Could not set up basepath mapping. Try running sls create_domain first.
Error: Cannot find AWS::ApiGateway::Deployment

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

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

  Your Environment Information ---------------------------
     OS:                     linux
     Node Version:           11.14.0
     Serverless Version:     1.41.1

From the package.json:

  "devDependencies": {
    "serverless-domain-manager": "^2.6.11",
    "serverless-step-functions": "^1.9.0"
  },
  "dependencies": {
    "serverless-plugin-aws-alerts": "^1.2.4",
    "serverless-pseudo-parameters": "^2.4.0"
  }

I made sure after the create_domain step in AWS console that the custom domain and route53 record were created. Locally I'm running WSL for ubuntu but we see the same issue on our jenkins box.

stevesuh avatar May 07 '19 17:05 stevesuh

any news about this ?

pedroresende avatar Feb 28 '20 11:02 pedroresende

Hi there

Hope you have been able to handle this issue There are no updates for the long time so closing this issue

Try our latest version of the plugin and let us know in case of any issue

rddimon avatar May 09 '23 11:05 rddimon