首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法访问AWS copilot部署的服务?

无法访问AWS copilot部署的服务?
EN

Stack Overflow用户
提问于 2021-03-11 23:05:14
回答 1查看 97关注 0票数 0

我有一个简单的后端服务,我刚刚用copilot部署了它。但是,我不知道去哪里访问它?

根据AWS控制台的说法,它正在运行并处于活动状态。我甚至可以在日志中看到它已经启动。

我的清单:

代码语言:javascript
复制
# The manifest for the "user-service" service.
# Read the full specification for the "Backend Service" type at:
#  https://aws.github.io/copilot-cli/docs/manifest/backend-service/

# Your service name will be used in naming your resources like log groups, ECS services, etc.
name: user-service
type: Backend Service

# Your service does not allow any traffic.

# Configuration for your containers and service.
image:
  # Docker build arguments. For additional overrides: https://aws.github.io/copilot-cli/docs/manifest/backend-service/#image-build
  build: ./Dockerfile
  port: 9000

cpu: 256       # Number of CPU units for the task.
memory: 512    # Amount of memory in MiB used by the task.
count: 1       # Number of tasks that should be running in your service.

# Optional fields for more advanced use-cases.
#
variables:                    # Pass environment variables as key value pairs.
  SERVER_PORT: 9000
  NODE_ENV: test
  
secrets:                      # Pass secrets from AWS Systems Manager (SSM) Parameter Store.
  ACCESS_TOKEN_SECRET: ACCESS_TOKEN_SECRET
  REFRESH_TOKEN_SECRET: REFRESH_TOKEN_SECRET
  MONGODB_URL: MONGODB_URL

# You can override any of the values defined above by environment.
environments:
  test:
    variables:
      NODE_ENV: test
#    count: 2               # Number of tasks to run for the "test" environment.

我的Dockerfile

代码语言:javascript
复制
# Check out https://hub.docker.com/_/node to select a new base image
FROM node:lts-buster-slim

# Set to a non-root built-in user `node`
USER node

# Create app directory (with user `node`)
RUN mkdir -p /home/node/app

WORKDIR /home/node/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY --chown=node package*.json ./

RUN npm install

# Bundle app source code
COPY --chown=node . .

RUN npm run build

# Bind to all network interfaces so that it can be mapped to the host OS
ENV HOST=0.0.0.0 PORT=3000

EXPOSE 9000
CMD [ "node", "." ]

这在本地工作得很好,使用docker-compose。但是在哪里可以找到部署的服务的URL呢?我查看了ECS控制台,任务有公网IP。然而,我无法连接到这一点。

这里缺少什么?

EN

回答 1

Stack Overflow用户

发布于 2021-03-12 00:18:57

Nm..是我的错。不应该通过互联网访问后端服务。它们公开端点,但应该通过服务发现相互通信(或前端)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66585178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档