deploy-infra.sh 914 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. STACK_NAME=joystream-node
  3. REGION=us-east-1
  4. CLI_PROFILE=joystream-user
  5. KEY_PATH=""
  6. EC2_INSTANCE_TYPE=t2.xlarge
  7. # Deploy the CloudFormation template
  8. echo -e "\n\n=========== Deploying main.yml ==========="
  9. aws cloudformation deploy \
  10. --region $REGION \
  11. --profile $CLI_PROFILE \
  12. --stack-name $STACK_NAME \
  13. --template-file main.yml \
  14. --no-fail-on-empty-changeset \
  15. --capabilities CAPABILITY_NAMED_IAM \
  16. --parameter-overrides \
  17. EC2InstanceType=$EC2_INSTANCE_TYPE
  18. # If the deploy succeeded, show the DNS name of the created instance
  19. if [ $? -eq 0 ]; then
  20. aws cloudformation list-exports \
  21. --profile $CLI_PROFILE \
  22. --query "Exports[?starts_with(Name,'${STACK_NAME}PublicIp')].Value" \
  23. --output text | sed 's/\t\t*/\n/g' > inventory
  24. echo -e "\n\n=========== Configuring the servers ==========="
  25. ansible-playbook -i inventory -v --private-key $KEY_PATH configure.yml
  26. fi