diff --git a/docs/_index.md b/docs/_index.md new file mode 100644 index 0000000000..42d1a2ab4d --- /dev/null +++ b/docs/_index.md @@ -0,0 +1,116 @@ +--- +title: Google Cloud (GCP) Classic +meta_desc: Learn how to use Pulumi's GCP Provider to reduce the complexity of managing and provisioning GCP resources. +layout: package +--- + +The Google Cloud Platform (GCP) provider for Pulumi can provision many of the cloud resources available in [Google Cloud](https://cloud.google.com/). + +The GCP provider must be configured with credentials to deploy and update resources in Google Cloud; see [Installation & Configuration](./installation-configuration) for instructions. + +**New to Pulumi and Google Cloud?** [Get started with Google Cloud using our tutorial](/docs/get-started/gcp) + + +## Example + + +{{< chooser language "typescript,python,go,csharp,java,yaml" >}} + +{{% choosable language javascript %}} + +```javascript +const gcp = require("@pulumi/gcp") + +const bucket = new gcp.storage.Bucket("my-bucket"); +``` + +{{% /choosable %}} +{{% choosable language typescript %}} + +```typescript +import * as gcp from "@pulumi/gcp"; + +const bucket = new gcp.storage.Bucket("my-bucket"); +``` + +{{% /choosable %}} +{{% choosable language python %}} + +```python +from pulumi_gcp import storage + +bucket = storage.Bucket('my-bucket') +``` + +{{% /choosable %}} +{{% choosable language go %}} + +```go +import ( + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" + "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + bucket, err := storage.NewBucket(ctx, "my-bucket", nil) + if err != nil { + return err + } + + return nil + }) +} +``` + +{{% /choosable %}} +{{% choosable language csharp %}} + +```csharp +using Pulumi; +using Gcp = Pulumi.Gcp; + +await Deployment.RunAsync(() => +{ + var bucket = new Gcp.Storage.Bucket("my-bucket"); +}); +``` + +{{% /choosable %}} + +{{% choosable language java %}} + +```java +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.gcp.storage.Bucket; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + private static void stack(Context ctx) { + final var bucket = new Bucket("my-bucket"); + ctx.export("bucketName", bucket.name()); + } +} +``` + +{{% /choosable %}} + +{{% choosable language yaml %}} + +```yaml +resources: + my-bucket: + type: gcp:storage:Bucket +``` + +{{% /choosable %}} + +{{< /chooser >}} + +Visit the [How-to Guides](./how-to-guides) to find step-by-step guides for specific scenarios like creating a serverless application using Google Cloud Functions or setting up a Google Kubernetes Engine (GKE) cluster. diff --git a/docs/installation-configuration.md b/docs/installation-configuration.md new file mode 100644 index 0000000000..6748f5c4ca --- /dev/null +++ b/docs/installation-configuration.md @@ -0,0 +1,97 @@ +--- +title: Google Cloud (GCP) Classic Installation & Configuration +meta_desc: How to set up credentials to use the Pulumi GCP Provider and choose configuration options to tailor the provider to suit your use case. +layout: package +--- + +## Installation + +The Google Cloud (GCP) Classic provider is available as a package in all Pulumi languages: + +* JavaScript/TypeScript: [`@pulumi/gcp`](https://www.npmjs.com/package/@pulumi/gcp) +* Python: [`pulumi-gcp`](https://pypi.org/project/pulumi-gcp/) +* Go: [`github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp`](https://github.com/pulumi/pulumi-gcp) +* .NET: [`Pulumi.Gcp`](https://www.nuget.org/packages/Pulumi.Gcp) +* Java: [`com.pulumi.gcp`](https://search.maven.org/search?q=com.pulumi.gcp) + +## Authentication Methods + +To provision resources with the Pulumi Google Cloud Provider, you need to have Google credentials. + +Pulumi can authenticate to Google Cloud via several methods: + +- Google Cloud CLI +- OpenID Connect (OIDC) +- Service account + +## Configuration + +There are a few different ways you can configure your Google Cloud credentials to work with Pulumi. + +### Authenticate using the CLI + +{{% configure-gcp type="gcp" %}} + +### Authenticate using a service account + +If you are using Pulumi in a non-interactive setting (such as a CI/CD system) you will need to [configure and use a service account](/registry/packages/gcp/service-account) instead. + +### Authenticate with dynamically generated credentials + +In addition to configuring the GCP provider locally, you also have the option to centralize your configurations using [Pulumi ESC (Environments, Secrets, and Configuration)](/docs/pulumi-cloud/esc/). Using this service will enable you to run Pulumi CLI commands with dynamically generated credentials, removing the need to configure and manage your credentials locally. + +To do this, you will need to complete the following steps: + +#### Configure OIDC between Pulumi and GCP + +Refer to the [Configuring OpenID Connect for GCP Guide](/docs/pulumi-cloud/oidc/gcp/) for the step-by-step process on how to do this. Once you have completed these steps, you can define and expose environment variables as shown below: + +```yaml +values: + gcp: + login: + fn::open::gcp-login: + project: + oidc: + workloadPoolId: + providerId: + serviceAccount: + environmentVariables: + GOOGLE_OAUTH_ACCESS_TOKEN: ${gcp.login.accessToken} + GOOGLE_PROJECT: ${gcp.login.project} + GOOGLE_REGION: + GOOGLE_ZONE: +``` + +#### Import your environment + +The last step is to update your project's stack settings file (`Pulumi..yaml`) to import your ESC environment as shown below: + +```yaml +environment: + - +``` + +Make sure to replace `` with the name of the ESC environment you created in the previous steps. + +You can test that your configuration is working by running the `pulumi preview` command. This will validate that your GCP resources can be deployed using the dynamically generated credentials in your environment file. + +{{< notes type="info" >}} +Make sure that your local environment does not have GCP credentials configured before running this command. You can logout by running the `gcloud auth revoke` command. +{{< /notes >}} + +To learn more about projecting environment variables in Pulumi ESC, refer to the [relevant Pulumi ESC documentation](/docs/pulumi-cloud/esc/environments/#projecting-environment-variables). + +## Configuration options + +Use `pulumi config set gcp: