Git Product home page Git Product logo

Comments (4)

pianomansam avatar pianomansam commented on July 30, 2024

@danifbento It will be helpful to see your serverless.yml file as well as Dockerfile or Docker image.

from aws-utils.

danifbento avatar danifbento commented on July 30, 2024

Thanks.

My serverless.yml is the following:

service: tests
provider:
  name: aws
  stage: dev
  region: eu-central-1
  runtime: nodejs8.1
  profile: default
  deploymentBucket: serverless.deploys

plugins:
  - serverless-appsync-plugin
  - serverless-appsync-offline
  - serverless-offline-sns
  - serverless-offline

custom:
  serverless-offline:
    host: 0.0.0.0
  serverless-offline-sns:
    port: 4002
    debug: false
  appsync-offline:
    port: 62222
    dynamodb:
      server:
        port: 8000
        inMemory: false
        seed: true
        sharedDb: true
  region: eu-central-1
  clientId: <clientID>
  appSync:
    name: deploy_test
    authenticationType: AMAZON_COGNITO_USER_POOLS
    userPoolConfig:
      awsRegion: eu-central-1
      defaultAction: ALLOW
      userPoolId: <poolId>
    schema: schema.graphql
    mappingTemplatesLocation: ./
    mappingTemplates:
        - dataSource: get_user
          type: Invite
          field: inviter
          request: resolver/request-mapping-template.json
          response: resolver/response-mapping-template.json
    dataSources:
          - type: AWS_LAMBDA
        name: get_user
        description: 'Get User'
        config:
            lambdaFunctionArn: arn:aws:lambda:${self:custom.region}:${self:custom.clientId}:function:fn-py-getuser
            functionName: getuser
functions:
  getuser:
    handler: getuser/handler.getuser
    timeout: 10
    runtime: python3.6
resources:
   Resources:
   (...)

And Dockerfile:

FROM ubuntu:18.04

ARG aws_access_key_id
ARG aws_secret_access_key

ENV GOPATH=/py-useraccount-tests
ENV GOBIN=$GOPATH/bin
ENV PATH=/root/.npm_packages/bin:$PATH
ENV NODE_PATH=/root/.npm_packages/lib/node_modules:$NODE_PATH

RUN \
    apt-get update && \
    apt-get install -y make git curl && \
    apt-get install -y python3 python3-pip && \
    apt-get install -y golang && \
    apt-get install -y npm && \
    apt-get install -y openssh-server zip && \
    apt-get install -y default-jre
RUN \
    pip3 install boto3

RUN \
    curl -sL https://deb.nodesource.com/setup_11.x | bash - && \
    apt-get install -y nodejs

RUN apt -y autoremove

RUN \
    go get -u github.com/aws/aws-lambda-go/lambda && \
    go get -u github.com/golang/dep/cmd/dep

COPY package.json /py-tests

RUN pip3 install aws-sam-cli jwt

RUN npm config set prefix /root/.npm_packages

RUN npm install -g try-thread-sleep@latest
RUN npm install -g serverless@latest --ignore-script spawn-sync
RUN npm install -g serverless-appsync-offline@latest --ignore-script spawn-sync
RUN npm install -g serverless-appsync-plugin@latest
RUN npm install -g serverless-offline@latest
RUN npm install -g serverless-offline-sns@latest
RUN npm install -g just-api --unsafe-perm=true --allow-root
RUN npm install -g aws-appsync
RUN npm install -g aws-sdk

RUN cd /root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/graphql-phone-type/ && npm install && npm run prepare
RUN mkdir /root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/\@conduitvc/dynamodb-emulator/emulator && cd /root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/\@conduitvc/dynamodb-emulator/ && npm run install 

WORKDIR "/py-tests"

COPY . /py-tests

RUN sls config credentials --provider aws --key "$aws_access_key_id" --secret "$aws_secret_access_key"

EXPOSE 62222 8000
CMD ["sls", "offline", "start"]

from aws-utils.

pianomansam avatar pianomansam commented on July 30, 2024

@danifbento after a quick skim, everything seems to look ok. I'm using this inside Docker as well, however, using docker-compose and have a separate container for DynamoDB. Any reason why that isn't an option for you?

from aws-utils.

danifbento avatar danifbento commented on July 30, 2024

Hello @pianomansam

Sorry for the late response. I started using in a separated container with docker-compose and it start to work. But now I have an error starting AppSync emulator saying ERROR on aws_auth saying that is not defined. The project is in a container, but it works on my PC but not in another ...

from aws-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.