1

I'm trying to setup a ready-to-run terraform template for some performance testing. It creates two EC2 instances in the same cluster placement group and preinstalls a bunch of tools. I don't know the SSH public keys of the users of it in advance and would prefer not to require users to copy and paste public keys into the terraform file before applying it.

For performance testing, I would need to copy files back and forth to the instance, i.e., source code to the instances and flamegraphs or logs back to the local machine. SSH is the standard solution, but as mentioned, it requires setting up SSH public keys. Another option would be to create a random S3 bucket and use the AWS CLI to copy files there and back, but it would require two steps to copy every file, i.e. to S3 and then to either the local machine or EC2 instance.

My question: Is there a way to copy files using the AWS CLI using e.g. SSM to an EC2 instance? Something that only requires having AWS credentials, i.e. what would already be required to execute terraform.

eof
  • 121
  • 3

1 Answers1

0

you can simply use the same pem keys that you had used at the time of ec2 instance creation with scp command to copy files back and forth to the instance.

asmath
  • 319
  • 1
  • 6
  • 1
    The point is that there's no PEM key, since you can create an EC2 instance without one if you're relying on SSM. However, I decided to drop this approach and just force the user of the template to provide an SSH public key. – eof Oct 17 '22 at 16:37