-
Notifications
You must be signed in to change notification settings - Fork 1
Amazon AWS
-
Serverless with AWS Lambda: https://www.youtube.com/watch?v=71cd5XerKss
- Install on ubuntu:
sudo apt install awscli
- https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
- https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_AWSCLI.html
- https://stackoverflow.com/questions/53095803/how-to-pull-ecs-docker-image-from-an-ec2-instance
- We need to add the IAM role
AmazonEC2ContainerRegistryReadOnly
to the EC2 instance.
Follow instruction indicated in your ECR's repository.
In your EC2 instance through SSH: (using AMI v2,, v1 doesn't support systemctl)
#!/bin/bash
#Install
sudo amazon-linux-extras install epel
# Install Docker
sudo yum install -y docker
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -a -G docker ec2-user
#Login will return `docker login -u AWS -p ...`
sudo $(aws ecr get-login --no-include-email --region eu-west-3)
#Pull the image
sudo docker pull Repository_URI_in_ECR
#sudo docker run -d --rm -p 80:9090 yt
# Install systemd service
echo W1Vu***BASE64***Ymx2 | base64 --decode > /etc/systemd/system/pblv.service
sudo systemctl enable /etc/systemd/system/pblv.service
systemctl status pblv
sudo systemctl start pblv
-
Doc run-instances: https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
-
aws configure
// Create an IAM and configure your console -
aws ec2 describe-instances
// List your instances -
aws ec2 run-instances --launch-template LaunchTemplateId=lt-0c6068275fbb8a825,Version=24
// Launch instance from template ID -
aws ec2 run-instances --launch-template LaunchTemplateName=pblv,Version=24
// Launch instance from template ID -
Kill all instances:
aws ec2 terminate-instances --instance-ids $(aws ec2 describe-instances --filters "Name=instance-state-name,Values=pending,running,stopped,stopping" --query "Reservations[].Instances[].[InstanceId]" --output text | tr '\n' ' ')