https://pulumi.com logo
#aws
Title
# aws
m

magnificent-church-42829

04/26/2022, 10:41 PM
i have a postgres hosted in an ec2 instance on a private subnet. I need to copy over and run some intialization scripts to open connections, create a database and user, etc. How would i go about copying over files and running commands for an instance in a private subnet? i know of the
command.remote.ConnectionArgs
,
command.remote.CopyFile
, and
command.remote.Command
but this wouldn’t work if the instance is in a private subnet.
b

billowy-army-68599

04/26/2022, 10:46 PM
this is a networking problem, you either need to use a bastion/jumpbox or a vpn
l

little-cartoon-10569

04/27/2022, 12:27 AM
Commands for initialization can also be handled through SSM (aws.ssm has the Document and Association resources that you'd need for this approach), or you can use userdata (cloud-init package's GetConfig function is the way to go here).
g

green-musician-49057

04/27/2022, 4:17 AM
You also pair pulumi's
command.local.Command
to use the aws CLI to invoke handy built-in AWS SSM / Systems Manager features, like running remote commands/scripts, or starting a port forwarding session. One of the nice parts of this approach is that your automations never touch your SSH keys...but there are some pre-reqs for using Systems Manager.
l

little-cartoon-10569

04/27/2022, 4:34 AM
And you still need access, since the command does run on the machine. cloud-init and SSM documents run on the machine itself, which makes it handy if the machine is on an isolated subnet, for example.
22 Views