I am new to AWS.
I had another issue with an instance, so I decided that I delete it and redo the steps to create a new one:
Here is the template I use
Resources:
AppNode:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.nano
ImageId: ami-06a719e5f8e22c33b
KeyName: influxdb_example_3
SecurityGroups:
- !Ref AppNodeSG
UserData: !Base64 |
#!/bin/bash
apt-get update -qq
apt-get install -y apt-transport-https ca-certificates
apt-key adv apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
apt-get update -qq apt-get purge lxc-docker || true
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd65] https://download.docker.com/linux/ubuntu bionic stable"
apt-get -y install linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-get -y install docker-ce
usermod -aG docker unbuntu
docker image pull quay.io/influxdb/influxdb:v2.0.2
docker container run -p 80:9999 quay.io/influxdb/influxdb:v2.0.2
AppNodeSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: for the app nodes that allow ssh
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: "80"
ToPort: "80"
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: "22"
ToPort: "22"
CidrIp: 0.0.0.0/0
This is how I create the stack
aws cloudformation create-stack \
--stack-name influxdb-trial-stack-2 \
--region eu-central-1 \
--template-body file://$PWD/stack.yaml
And this is how I access it:
ssh -i influxdb_example_3.pem \
ubuntu@ec2-18-159-XXX-XX.eu-central-1.compute.amazonaws.com
I manage to create the stack/instance and access it. Since the second attempt, however, whenever I try to do anything there with sudo
it reacts very slowly and I got the unable to resolve host ip-172-31-xx-xxx: Temporary failure in name resolution
message. I have gone through the steps three times already, but it always comes down to this.
The nearest thing I found was here: https://forums.aws.amazon.com/thread.jspa?threadID=132414.
Based on that, I inserted the private ip/dns into etc/hosts
, but it did not help (though it talks about 'network restart'. Is it the same as instance reboot?)
I understand that there are different manual ways to fix this issue, but as in the first time it did work for me, and as I would assume that the stack creation process is automatic, I suspect that there is some config/cache/??? issue I am not aware of.
Any suggestions are appreciated.
It turned out that using a different AMI solved the issue.
My second and further setups used a different AMI from the first just I forgot about this and did not even think that the AMI could be the problem.