Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a ESC+PSP tutorial #13349

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adding a ESC+PSP tutorial #13349

wants to merge 1 commit into from

Conversation

IaroslavTitov
Copy link
Contributor

Proposed changes

  • Adding a new tutorial on how to use ESC to configure PSP
  • I still need to ask for a cover picture to be made before merging, but want to get a go ahead on the title before I request it, to avoid double work

Related issues

@pulumi-bot
Copy link
Collaborator

@IaroslavTitov IaroslavTitov marked this pull request as ready for review November 14, 2024 18:03
@IaroslavTitov IaroslavTitov requested a review from a team as a code owner November 14, 2024 18:03
Copy link
Contributor

@seanyeh seanyeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 just some small wording suggestions

$ pulumi login

Manage your Pulumi stacks by logging in.
Run `esc login --help` for alternative login options.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be pulumi login?


## Obtain a personal access token

Next, you'll also need a Pulumi Cloud [personal access token](/docs/pulumi-cloud/access-management/access-tokens/#personal-access-tokens). Create a short-lived access token for this tutorial, copy it into your current shell to login into Pulumi Cloud. Keep the token creation page open in a separate tab, or paste it somewhere temporarily to use in the next step of the tutorial.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe ... Create a short-lived access token for this tutorial and copy it into your current shell to login into Pulumi Cloud. Be sure to keep track of this token as you will need it for the next step of the tutorial.?


## Brief Explanation

Pulumi Service Provider is used to create Pulumi Cloud resources using Pulumi IaC Programs. Just like an S3 bucket is created using an AWS provider, PSP allows creation of things like Environments, Environment Version Tags, Environment Webhooks, and much more. In order to authenticate with Pulumi Cloud, PSP uses the same personal access token (PAT for short!) as Pulumi CLI. This is where ESC comes in!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulumi Service Provider (PSP) is a Pulumi provider for creating and configuring Pulumi Cloud resources. ...

---

{{% notes %}}
This tutorial is all about using ESC with Pulumi Service Provider (PSP for short!). However, using ESC is an encouragement rather than a requirement. If you *don't* want to use ESC, refer to [PSP setup docs](/registry/packages/pulumiservice/installation-configuration/) instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personal preference but Pulumi Service Provider (PSP) is probably fine (don't need for short)


Instead of providing PAT as an environment variable, risking losing or leaking it, we will create an ESC Environment and store the PAT there. We will then import this environment into the configuration of a new stack, in which we will create Pulumi Cloud resources

## Create a new ESC project and environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer just Create a new ESC environment. it sounds like we're creating 2 things if we say project and environment

fn::secret: % FILL IN PAT HERE %
```

If you are *not* using Pulumi Self-hosted, just remove the line containing `apiUrl`. This optional field configures custom Pulumi Cloud backend, and is not needed for most users.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would probably just add the opposite, to add the custom url if you are using self hosted


If you are *not* using Pulumi Self-hosted, just remove the line containing `apiUrl`. This optional field configures custom Pulumi Cloud backend, and is not needed for most users.

Once you fill in your previously created PAT, click `Save` on the top right. This will update your new environment's definition with the values you just added. Note how the plain text PAT value you pasted in was converted into a secret. It is now securely stored within Pulumi Cloud, removing the risk of losing or leaking the PAT, while your stacks are still able to decrypt and use it. Feel free to close the token creation page now, we won't need it again!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the plaintext PAT was converted into a secret value.
Probably don't need the last sentence if we changed the line above when obtaining a PAT


Now it's time to create a new Pulumi Program that will use the new Environment and PSP to create more Pulumi Cloud resources!

Create a new folder in your shell (for example `esc-psp-tutorial`) and navigate into it. Then, run `pulumi new`, and navigate the menu to create a new stack from a template called `typescript`. Fill in the project name as `esc-psp-tutorial`, and the stack name as `%ORG NAME%/dev`, filling in your actual organization name (for the rest of the tutorial, `tutorials` will be used), and `dev` is the name of the new stack.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dev as the name of the new stack"

- creds/psp
```

In the config files, `environment` field lets you specify an array of ESC Environments to import. In this case, we only want to import the Environment we created above, `creds/psp`, where `creds` is the ESC project name and `psp` is the Environment name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Here, the environment field"

probably don't need "where creds is the ESC project name and psp is the Environment name."


### Wrapping up

You have learned how to create ESC environments in the Pulumi Cloud console, import them into IaC stacks and even create Environments using the Pulumi Service Provider. The environment you created, `creds/psp` can now be easily re-used between your stacks, or used to compose more complicated environments, using [Environment imports](https://www.pulumi.com/docs/esc/environments/imports/). Using what you know now, you can easily create other `creds` Environments for ther providers. For example, `creds/aws` or `creds/azure`!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would replace complicated with complex - has a more positive connotation

how about "Using what you know now, you can easily create other Environments under the creds project to store credentials for other services."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants