I have the following code for smoke test job
smoke-test:
docker:
- image: python:3.9.0-alpine
steps:
- checkout
- run:
name: Install dependencies
command: |
apk add --update --no-cache curl aws-cli tar gzip nodejs npm
- run:
name: Get backend url
command: |
export BACKEND_IP=$(aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].PublicIpAddress' \
--filters Name=tag:aws:cloudformation:stack-name,Values=udapeople-backend-${CIRCLE_WORKFLOW_ID:0:7} \
--output text)
export API_URL="http://${BACKEND_IP}:3030"
echo "${API_URL}"
if curl "${API_URL}/api/status" | grep "ok"
then
return 0
else
return 1
fi
- run:
name: Frontend smoke test.
command: |
URL="http://udapeople-${CIRCLE_WORKFLOW_ID:0:7}.s3-website-us-east-1.amazonaws.com/#/employees"
echo ${URL}
if curl -s ${URL} | grep "Welcome"
then
return 1
else
return 1
fi
it keeps give me this error
http://54.205.67.197:3030
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (7) Failed to connect to 54.205.67.197 port 3030 after 0 ms: Connection refused
Exited with code exit status 1
CircleCI received exit code 1
here is my code for deploy-backend
deploy-backend:
docker:
- image: python:3.9.0-alpine
steps:
- checkout
- restore_cache:
keys: [backend-build]
- add_ssh_keys:
fingerprints: ["27:4e:39:ad:07:93:4a:f8:f0:94:66:ec:fd:8d:46:9f"]
- attach_workspace:
at: ~/
- run:
name: Install dependencies
command: |
apk add --update --no-cache tar gzip nodejs npm aws-cli ansible curl
- run:
name: Deploy backend
command: |
cd backend
npm i
npm run build
cd ..
tar -C backend -czvf artifact.tar.gz .
cd .circleci/ansible
echo "Contents of the inventory.txt file is -------"
cat inventory.txt
ansible-playbook -i inventory.txt deploy-backend.yml
- save_cache:
paths: [backend/node_modules]
key: backend-build
- destroy_environment:
id: ${CIRCLE_WORKFLOW_ID:0:7}
when: on_fail
and here is my code for deploy-backend code
---
- name: "Deploy and start backend server"
hosts: web
user: ubuntu
gather_facts: false
vars:
- ansible_python_interpreter: /usr/bin/python3
- ansible_host_key_checking: false
- ansible_stdout_callback: yaml
pre_tasks:
- name: "wait 600 seconds for target connection to become reachable/usable."
wait_for_connection:
timeout: 600
- name: "install python for Ansible."
command: |
sudo apt install npm -y
sudo npm install python
sudo apt update
sudo apt install ansible -y
sudo ansible --version
environment:
- ENVIRONMENT: production
- TYPEORM_CONNECTION: "{{ lookup('env', 'TYPEORM_CONNECTION') }}"
- TYPEORM_ENTITIES: "{{ lookup('env', 'TYPEORM_ENTITIES') }}"
- TYPEORM_HOST: "{{ lookup('env', 'TYPEORM_HOST') }}"
- TYPEORM_PORT: "{{ lookup('env', 'TYPEORM_PORT') }}"
- TYPEORM_USERNAME: "{{ lookup('env', 'TYPEORM_USERNAME') }}"
- TYPEORM_PASSWORD: "{{ lookup('env', 'TYPEORM_PASSWORD') }}"
- TYPEORM_DATABASE: "{{ lookup('env', 'TYPEORM_DATABASE') }}"
- TYPEORM_MIGRATIONS: "{{ lookup('env', 'TYPEORM_MIGRATIONS')}}"
- TYPEORM_MIGRATIONS_DIR: "{{ lookup('env', 'TYPEORM_MIGRATIONS_DIR')}}"
roles:
- deploy
can anyone please tell me what could be the problem ?