@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
563 lines • 22.9 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* An environment for running orchestration tasks.
*
* Environments run Apache Airflow software on Google infrastructure.
*
* To get more information about Environments, see:
*
* * [Managed Service for Apache Airflow documentation](https://docs.cloud.google.com/composer/docs)
* * [Managed Airflow API documentation](https://docs.cloud.google.com/composer/docs/reference/rest/v1beta1/projects.locations.environments)
* * How-to Guides for Managed Airflow (Gen 3)
* * [Creating environments](https://docs.cloud.google.com/composer/docs/composer-3/create-environments)
* * [Scaling environments](https://docs.cloud.google.com/composer/docs/composer-3/scale-environments)
* * [Change environment networking type (Private or Public IP)](https://docs.cloud.google.com/composer/docs/composer-3/change-networking-type)
* * [Connect an environment to a VPC network](https://docs.cloud.google.com/composer/docs/composer-3/connect-vpc-network)
* * How-to Guides for Managed Airflow (Gen 2)
* * [Creating environments](https://docs.cloud.google.com/composer/docs/composer-2/create-environments)
* * [Scaling environments](https://docs.cloud.google.com/composer/docs/composer-2/scale-environments)
* * [Configuring Shared VPC](https://docs.cloud.google.com/composer/docs/composer-2/configure-shared-vpc)
* * [Apache Airflow Documentation](http://airflow.apache.org/)
*
* > **Note**
* Managed Airflow (Legacy Gen 1) is in the post-maintenance mode. Google
* doesn't release any further updates to Managed Service for
* Managed Airflow (Legacy Gen 1), including new versions of Airflow, bugfixes,
* and security updates. We recommend using Managed Airflow (Gen 3) or
* Managed Airflow (Gen 2) instead.
*
* Several special considerations apply to using Terraform with
* Managed Service for Apache Airflow:
*
* * The Environment resource is based on several layers of Google Cloud
* infrastructure. Terraform doesn't manage these underlying resources. For
* example, in Managed Airflow (Gen 2), this includes a Google Kubernetes
* Engine cluster, Cloud Storage, and Compute networking resources.
* * Creating or updating an environment usually takes around 25 minutes.
* * In some cases, errors in the configuration are detected and reported only
* during the process of environment creation. If you encounter such
* errors, please verify that your configuration is valid for the Managed
* Airflow environment you are creating before filing bugs for the Terraform
* provider.
* * **Environments have Google Cloud Storage buckets that are not automatically
* deleted** with the environment.
* See [Delete environments](https://docs.cloud.google.com/composer/docs/composer-3/delete-environments)
* for more information.
* * See
* [Troubleshooting pages](https://docs.cloud.google.com/composer/docs/composer-3/troubleshooting-environment-creation)
* if you encounter problems.
*
* ## Example Usage
*
* ### Basic usage in Managed Airflow (Gen 3)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const test = new gcp.composer.Environment("test", {
* name: "example-composer-env",
* region: "us-central1",
* config: {
* softwareConfig: {
* imageVersion: "composer-3-airflow-2",
* },
* },
* });
* ```
*
* ### Basic usage in Managed Airflow (Gen 2)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const test = new gcp.composer.Environment("test", {
* name: "example-composer-env",
* region: "us-central1",
* config: {
* softwareConfig: {
* imageVersion: "composer-2-airflow-2",
* },
* },
* });
* ```
*
* ### Basic Usage in Managed Airflow (Legacy Gen 1)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const test = new gcp.composer.Environment("test", {
* name: "example-composer-env",
* region: "us-central1",
* config: {
* softwareConfig: {
* imageVersion: "composer-1-airflow-2",
* },
* },
* });
* ```
*
* ### With environment resources configuration
*
* > **Note**
* To use custom service accounts, you must give at least the
* `role/composer.worker` role to the service account of the Managed Airflow
* environment. For more information, see the
* [Access Control](https://docs.cloud.google.com/composer/docs/composer-3/access-control)
* page in the Managed Airflow documentation.
* You might need to assign additional roles depending on specific workflows
* that the Airflow DAGs will be running.
*
* ### Environment resources configuration in Managed Airflow (Gen 3)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const testAccount = new gcp.serviceaccount.Account("test", {
* accountId: "composer-env-account",
* displayName: "Test Service Account for Managed Airflow Environment",
* });
* const test = new gcp.composer.Environment("test", {
* name: "example-composer-env-tf-c3",
* region: "us-central1",
* config: {
* softwareConfig: {
* imageVersion: "composer-3-airflow-2",
* },
* workloadsConfig: {
* scheduler: {
* cpu: 0.5,
* memoryGb: 2,
* storageGb: 1,
* count: 1,
* },
* triggerer: {
* cpu: 0.5,
* memoryGb: 1,
* count: 1,
* },
* dagProcessor: {
* cpu: 1,
* memoryGb: 2,
* storageGb: 1,
* count: 1,
* },
* webServer: {
* cpu: 0.5,
* memoryGb: 2,
* storageGb: 1,
* },
* worker: {
* cpu: 0.5,
* memoryGb: 2,
* storageGb: 1,
* minCount: 1,
* maxCount: 3,
* },
* },
* environmentSize: "ENVIRONMENT_SIZE_SMALL",
* nodeConfig: {
* serviceAccount: testAccount.name,
* },
* },
* });
* const composer_worker = new gcp.projects.IAMMember("composer-worker", {
* project: "your-project-id",
* role: "roles/composer.worker",
* member: pulumi.interpolate`serviceAccount:${testAccount.email}`,
* });
* ```
*
* ### Environment resources configuration in Managed Airflow (Gen 2)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const testNetwork = new gcp.compute.Network("test", {
* name: "composer-test-network3",
* autoCreateSubnetworks: false,
* });
* const testSubnetwork = new gcp.compute.Subnetwork("test", {
* name: "composer-test-subnetwork",
* ipCidrRange: "10.2.0.0/16",
* region: "us-central1",
* network: testNetwork.id,
* });
* const testAccount = new gcp.serviceaccount.Account("test", {
* accountId: "composer-env-account",
* displayName: "Test Service Account for Managed Airflow",
* });
* const test = new gcp.composer.Environment("test", {
* name: "example-composer-env-tf-c2",
* region: "us-central1",
* config: {
* softwareConfig: {
* imageVersion: "composer-2-airflow-2",
* },
* workloadsConfig: {
* scheduler: {
* cpu: 0.5,
* memoryGb: 1.875,
* storageGb: 1,
* count: 1,
* },
* webServer: {
* cpu: 0.5,
* memoryGb: 1.875,
* storageGb: 1,
* },
* worker: {
* cpu: 0.5,
* memoryGb: 1.875,
* storageGb: 1,
* minCount: 1,
* maxCount: 3,
* },
* },
* environmentSize: "ENVIRONMENT_SIZE_SMALL",
* nodeConfig: {
* network: testNetwork.id,
* subnetwork: testSubnetwork.id,
* serviceAccount: testAccount.name,
* },
* },
* });
* const composer_worker = new gcp.projects.IAMMember("composer-worker", {
* project: "your-project-id",
* role: "roles/composer.worker",
* member: pulumi.interpolate`serviceAccount:${testAccount.email}`,
* });
* ```
*
* ### Environment resources configuration in Managed Airflow (Legacy Gen 1)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const testNetwork = new gcp.compute.Network("test", {
* name: "composer-test-network",
* autoCreateSubnetworks: false,
* });
* const testSubnetwork = new gcp.compute.Subnetwork("test", {
* name: "composer-test-subnetwork",
* ipCidrRange: "10.2.0.0/16",
* region: "us-central1",
* network: testNetwork.id,
* });
* const testAccount = new gcp.serviceaccount.Account("test", {
* accountId: "composer-env-account",
* displayName: "Test Service Account for Managed Airflow",
* });
* const test = new gcp.composer.Environment("test", {
* name: "example-composer-env",
* region: "us-central1",
* config: {
* softwareConfig: {
* imageVersion: "composer-1-airflow-2",
* },
* nodeCount: 4,
* nodeConfig: {
* zone: "us-central1-a",
* machineType: "n1-standard-1",
* network: testNetwork.id,
* subnetwork: testSubnetwork.id,
* serviceAccount: testAccount.name,
* },
* databaseConfig: {
* machineType: "db-n1-standard-2",
* },
* webServerConfig: {
* machineType: "composer-n1-webserver-2",
* },
* },
* });
* const composer_worker = new gcp.projects.IAMMember("composer-worker", {
* role: "roles/composer.worker",
* member: pulumi.interpolate`serviceAccount:${testAccount.email}`,
* });
* ```
*
* ### Networking configuration in Managed Airflow (Gen 3)
*
* In Managed Airflow (Gen 3), networking configuration is simplified compared to
* previous versions. You don't need to specify network ranges, and can attach
* custom VPC networks to your environment.
*
* > **Note**
* It's not possible to detach a VPC network using Terraform. Instead, you can
* attach a different VPC network in its place, or detach the network using
* other tools like Google Cloud CLI.
*
* Use Private IP networking:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const example = new gcp.composer.Environment("example", {
* name: "example-environment",
* region: "us-central1",
* config: {
* enablePrivateEnvironment: true,
* },
* });
* ```
*
* Attach a custom VPC network (Managed Airflow creates a new network attachment):
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const example = new gcp.composer.Environment("example", {
* name: "example-environment",
* region: "us-central1",
* config: {
* nodeConfig: {
* network: "projects/example-project/global/networks/example-network",
* subnetwork: "projects/example-project/regions/us-central1/subnetworks/example-subnetwork",
* },
* },
* });
* ```
*
* Attach a custom VPC network (use an existing network attachment):
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const example = new gcp.composer.Environment("example", {
* name: "example-environment",
* region: "us-central1",
* config: {
* nodeConfig: {
* composerNetworkAttachment: String(Number(projects) / Number(example_project) / Number(regions) / Number(us_central1) / Number(networkAttachments) / Number(example_network_attachment)),
* },
* },
* });
* ```
*
* If you specify an existing network attachment that you also manage in
* Terraform, then Terraform will revert changes to the attachment that were done
* by Managed Airflow when you apply configuration changes. As a result, the
* environment will no longer use the attachment. To address this, make sure that
* Terraform ignores changes to the `producerAcceptLists` parameter of the
* attachment, as follows:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const example = new gcp.compute.NetworkAttachment("example", {});
* const exampleEnvironment = new gcp.composer.Environment("example", {
* name: "example-environment",
* region: "us-central1",
* config: {
* nodeConfig: {
* composerNetworkAttachment: example.id,
* },
* },
* });
* ```
*
* ## Import
*
* Environment can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{region}}/environments/{{name}}`
* * `{{project}}/{{region}}/{{name}}`
* * `{{name}}`
*
* When using the
* `pulumi import` command,
* Environment can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:composer/environment:Environment default projects/{{project}}/locations/{{region}}/environments/{{name}}
* $ pulumi import gcp:composer/environment:Environment default {{project}}/{{region}}/{{name}}
* $ pulumi import gcp:composer/environment:Environment default {{name}}
* ```
*/
export declare class Environment extends pulumi.CustomResource {
/**
* Get an existing Environment resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: EnvironmentState, opts?: pulumi.CustomResourceOptions): Environment;
/**
* Returns true if the given object is an instance of Environment. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is Environment;
/**
* Configuration parameters for this environment.
*/
readonly config: pulumi.Output<outputs.composer.EnvironmentConfig>;
/**
* Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE".
* When a 'terraform destroy' or 'terraform apply' would delete the instance,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
readonly deletionPolicy: pulumi.Output<string>;
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
*/
readonly effectiveLabels: pulumi.Output<{
[key: string]: string;
}>;
/**
* User-defined labels for this environment. The labels map can contain no more than 64 entries. Entries of the labels map are UTF8 strings that comply with the following restrictions: Label keys must be between 1 and 63 characters long and must conform to the following regular expression: a-z?. Label values must be between 0 and 63 characters long and must conform to the regular expression (a-z?)?. No more than 64 labels can be associated with a given environment. Both keys and values must be <= 128 bytes in size.
*
* **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
* Please refer to the field 'effective_labels' for all of the labels present on the resource.
*/
readonly labels: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* Name of the environment.
*/
readonly name: pulumi.Output<string>;
/**
* The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
*/
readonly project: pulumi.Output<string>;
/**
* The combination of labels configured directly on the resource and default labels configured on the provider.
*/
readonly pulumiLabels: pulumi.Output<{
[key: string]: string;
}>;
/**
* The location or Compute Engine region for the environment.
*/
readonly region: pulumi.Output<string>;
/**
* Configuration options for storage used by Composer environment.
*/
readonly storageConfig: pulumi.Output<outputs.composer.EnvironmentStorageConfig>;
/**
* Create a Environment resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: EnvironmentArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Environment resources.
*/
export interface EnvironmentState {
/**
* Configuration parameters for this environment.
*/
config?: pulumi.Input<inputs.composer.EnvironmentConfig | undefined>;
/**
* Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE".
* When a 'terraform destroy' or 'terraform apply' would delete the instance,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
*/
effectiveLabels?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* User-defined labels for this environment. The labels map can contain no more than 64 entries. Entries of the labels map are UTF8 strings that comply with the following restrictions: Label keys must be between 1 and 63 characters long and must conform to the following regular expression: a-z?. Label values must be between 0 and 63 characters long and must conform to the regular expression (a-z?)?. No more than 64 labels can be associated with a given environment. Both keys and values must be <= 128 bytes in size.
*
* **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
* Please refer to the field 'effective_labels' for all of the labels present on the resource.
*/
labels?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* Name of the environment.
*/
name?: pulumi.Input<string | undefined>;
/**
* The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* The combination of labels configured directly on the resource and default labels configured on the provider.
*/
pulumiLabels?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* The location or Compute Engine region for the environment.
*/
region?: pulumi.Input<string | undefined>;
/**
* Configuration options for storage used by Composer environment.
*/
storageConfig?: pulumi.Input<inputs.composer.EnvironmentStorageConfig | undefined>;
}
/**
* The set of arguments for constructing a Environment resource.
*/
export interface EnvironmentArgs {
/**
* Configuration parameters for this environment.
*/
config?: pulumi.Input<inputs.composer.EnvironmentConfig | undefined>;
/**
* Whether Terraform will be prevented from destroying the instance. Defaults to "DELETE".
* When a 'terraform destroy' or 'terraform apply' would delete the instance,
* the command will fail if this field is set to "PREVENT" in Terraform state.
* When set to "ABANDON", the command will remove the resource from Terraform
* management without updating or deleting the resource in the API.
* When set to "DELETE", deleting the resource is allowed.
*/
deletionPolicy?: pulumi.Input<string | undefined>;
/**
* User-defined labels for this environment. The labels map can contain no more than 64 entries. Entries of the labels map are UTF8 strings that comply with the following restrictions: Label keys must be between 1 and 63 characters long and must conform to the following regular expression: a-z?. Label values must be between 0 and 63 characters long and must conform to the regular expression (a-z?)?. No more than 64 labels can be associated with a given environment. Both keys and values must be <= 128 bytes in size.
*
* **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
* Please refer to the field 'effective_labels' for all of the labels present on the resource.
*/
labels?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* Name of the environment.
*/
name?: pulumi.Input<string | undefined>;
/**
* The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
*/
project?: pulumi.Input<string | undefined>;
/**
* The location or Compute Engine region for the environment.
*/
region?: pulumi.Input<string | undefined>;
/**
* Configuration options for storage used by Composer environment.
*/
storageConfig?: pulumi.Input<inputs.composer.EnvironmentStorageConfig | undefined>;
}
//# sourceMappingURL=environment.d.ts.map