Skip to content

SSM : Inaccessible host: ssm.'. This service may not be available in the .......' region. #4251

Closed

Description

@anantab

Serverless throws error when AWS region is referenced from another variable or from another file.

Activity

  1. lorengordon commented on Sep 13, 2017

    @lorengordon
    Contributor

    @anantab Can you share a serverless.yml setup that reproduces the error?

  2. anantab commented on Sep 14, 2017

    @anantab
    Author

    Here is what my serverless.yml looks like

    service: ${self:custom.config.SERVICE_NAME}
    custom : 
       defaultStage: dev
       defaultProfile: default
       currentStage: ${opt:stage, self:custom.defaultStage}
       config:  ${file(../config/env-${self:custom.currentStage}/infrastructure.yml)}
       configDB:  ${file(../config/env-${self:custom.currentStage}/lamdaConfigs.yml)}
       AuthorizerTTL: 0
      
    provider:
       name: aws
       runtime: ${self:custom.config.NODEJS_RUNTIME_VERSION}
       stage: ${self:custom.currentStage}
       region : ${self:custom.config.AWS_REGION}
       timeout: 60
     
     environment:
        DB_PASSWORD: ${ssm:dbPassword}
    ......

    The error I am getting is
    Inaccessible host: ssm.'. This service may not be available in the ${self:custom.config.AWS_REGION}' region.

  3. lorengordon commented on Sep 14, 2017

    @lorengordon
    Contributor

    Ok, then as best I can tell the AWS region which you are using just does not currently support SSM. What region are you using? Here are the regions that support SSM:

  4. anantab commented on Sep 14, 2017

    @anantab
    Author

    Hi,
    I am using ap-southeast-2 which supports SSM. When I hardcode region in serverless.yml, I do not get the error. I think the error is due to trying to fetch SSM variable before serverless has resolved variable reference.

  5. pmuens commented on Sep 14, 2017

    @pmuens
    Contributor

    Thanks for opening @anantab and thanks for providing help here @lorengordon 👍

    I think the error is due to trying to fetch SSM variable before serverless has resolved variable reference.

    @anantab I think you're correct. The AWS_REGION variable is not be populated yet since the SSM Serverless Variable is itself a variable.

    AFAIK there's no way to do this right now (other than hardcoding the region).

    Do you have any creative idea how this could be solved in another way @eahefnawy?

  6. lorengordon commented on Sep 14, 2017

    @lorengordon
    Contributor

    The AWS_REGION variable is not be populated yet since the SSM Serverless Variable is itself a variable

    Ahh, ok, so looking at the code this would be a problem for all variable syntaxes that resolve the variable from AWS services, including CF and S3, not just SSM.

  7. lorengordon commented on Sep 14, 2017

    @lorengordon
    Contributor

    @anantab Does it work if you remove the region line from serverless.yml and pass it on the command line? i.e. serverless package --region ap-southeast-2?

  8. lorengordon commented on Sep 14, 2017

    @lorengordon
    Contributor

    Here's a minimal serverless.yml to reproduce the error and test any patch:

    service: hello
    
    custom:
      region: "us-east-1"
    
    provider:
      name: aws
      region: ${self:custom.region}
      runtime: nodejs6.10
      environment:
        BARFOO: ${ssm:/bar/foo}
    
    functions:
      hello:
        handler: handler.hello
    

    error with serverless package:

      Serverless Error ---------------------------------------
    
      Inaccessible host: `ssm.'. This service may not be available in the `${self:custom.region}' region.
    
  9. lorengordon commented on Sep 14, 2017

    @lorengordon
    Contributor

    And passing the region on the command line does indeed work.

    serverless.yml:

    service: hello
    
    provider:
      name: aws
      runtime: nodejs6.10
      environment:
        BARFOO: ${ssm:/bar/foo}
    
    functions:
      hello:
        handler: handler.hello
    
    > serverless package --region us-east-2
    Serverless: Packaging service...
    Serverless: Excluding development dependencies...
    > grep FOO .serverless/cloudformation-template-update-stack.json
                "BARFOO": "bar"
    
  10. pmuens commented on Sep 14, 2017

    @pmuens
    Contributor

    Thanks for taking a deep dive into this @lorengordon 👍

    Yes, this is true for all the Serverless Variables in the variables system but it's great that you can pass in the region as a CLI option as a workaround.

    Closing this for now since there's a workaround available and adding this enhancement requires a complete Serverless Variables re-write / re-architecturing.

  11. kumaresansv commented on Nov 2, 2017

    @kumaresansv

    I stumbled on something that allowed me to keep "Profile" and "Region" as serverless variables while referring to a CF variable from AWS.

    Below code in serverless.yml did not work

    profile: ${self:custom.private.profile}
    region: ${self:custom.private.region}
    stage: ${opt:stage, self:custom.private.stage}

    events:
    - stream:
    type: dynamodb
    arn: ${cf:mystack-dev.myStreamArn}

    Whereas , if I replace the stage in my CF Arn with a variable, it worked like a charm
    profile: ${self:custom.private.profile}
    region: ${self:custom.private.region}
    stage: ${opt:stage, self:custom.private.stage}

    events:
    - stream:
    type: dynamodb
    arn: ${cf:mystack-${self:custom.private.stage}.myStreamArn}

    Try this if it helps.

  12. sonya commented on Sep 21, 2018

    @sonya

    I noticed that I no longer get this error when I forget to include the region parameter while deploying a stack that uses SSM. Was this fixed in a recent release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions