I made only very small progress. Before we had the problem that the specified key was created, but the instance didn't use it.
I solved this, see https://github.com/os-autoinst/openQA/pull/4880/commits/59241dcbdd0b309d8426b4f6e466632dfc1d38fa
We need to tell aws which key_name to use.
Then it also shows up in the AWS Console.
Still I couldn't ssh (permission denied).
What I did:
ssh-keygen -t rsa -m PEM -f webuidemo.pem
ssh-keygen -y -f webuidemo.pem >webuidemo.pub
I used the content of webuidemo.pub for the public_key value.
ssh -i webuidemo.pem -o IdentitiesOnly=yes ec2-user@ip -v
ssh -i webuidemo.pem -o IdentitiesOnly=yes root@ip -v
...
debug1: Next authentication method: publickey
debug1: Trying private key: webuidemo.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
ec2-user@ip: Permission denied (publickey).
I also tried with a key that I created over the webui.
I had to comment out the usser_data because with it the instance
never opened its ssh port, so I assume user_data must have a
different type of content, or the script failed for some reason,
but we never see the output anywhere, so we can just guess.
Also I had to use a new image_id as it failed to find the one
we had before.
I also tried to create an instance from the image via the webui. It resulted in the same problem.
SSH port was open, but I got permission denied.
cd container/terraform
docker run --rm -it --name terraform -v $(pwd):/workspace -w /workspace hashicorp/terraform:light validate
docker run --rm -it --name terraform -v $(pwd):/workspace -w /workspace hashicorp/terraform:light init ## this needs to be run once; providers will be downloaded to a local folder
docker run --rm -it --name localstack -p 4566:4566 -p 4510-4559:4510-4559 -v $(pwd):/workspace -w /workspace localstack/localstack:latest
docker run --rm -it --network host --name terraform -v $(pwd):/workspace -w /workspace hashicorp/terraform:light apply # this will create the instance on aws