1. Packages
  2. AWS Classic
  3. How-to Guides
  4. AWS WebServer with Manual Provisioning (in Python)

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.1 published on Thursday, Apr 18, 2024 by Pulumi

AWS WebServer with Manual Provisioning (in Python)

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.1 published on Thursday, Apr 18, 2024 by Pulumi

    View Code

    This demonstrates using the pulumi_command package to accomplish post-provisioning configuration steps.

    Using these building blocks, one can accomplish much of the same as Terraform provisioners.

    Running the Example

    First, create a stack, using pulumi stack init.

    Next, generate an OpenSSH keypair for use with your server - as per the AWS Requirements

    $ ssh-keygen -t rsa -f rsa -b 4096 -m PEM
    

    This will output two files, rsa and rsa.pub, in the current directory. Be sure not to commit these files!

    We then need to configure our stack so that the public key is used by our EC2 instance, and the private key used for subsequent SCP and SSH steps that will configure our server after it is stood up.

    $ cat rsa.pub | pulumi config set publicKey --
    $ cat rsa | pulumi config set privateKey --secret --
    

    Notice that we’ve used --secret for privateKey. This ensures the private key is stored as an encrypted Pulumi secret.

    Also set your desired AWS region:

    $ pulumi config set aws:region us-west-2
    

    From there, you can run pulumi up and all resources will be provisioned and configured.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.31.1 published on Thursday, Apr 18, 2024 by Pulumi