UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

629 lines (628 loc) 24.4 kB
import * as pulumi from "@pulumi/pulumi"; import { input as inputs, output as outputs } from "../types"; /** * Provides an OBS bucket resource. * * ## Example Usage * ### Private Bucket with Tags * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * * const bucket = new huaweicloud.Obs.Bucket("b", { * acl: "private", * bucket: "my-tf-test-bucket", * tags: { * Env: "Test", * foo: "bar", * }, * }); * ``` * ### Enable versioning * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * * const bucket = new huaweicloud.Obs.Bucket("b", { * acl: "private", * bucket: "my-tf-test-bucket", * versioning: true, * }); * ``` * ### Enable Logging * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const agencyName = config.requireObject("agencyName"); * const logBucket = new huaweicloud.obs.Bucket("logBucket", { * bucket: "my-tf-log-bucket", * acl: "log-delivery-write", * }); * const bucket = new huaweicloud.obs.Bucket("bucket", { * bucket: "my-tf-test-bucket", * acl: "private", * loggings: [{ * targetBucket: logBucket.id, * targetPrefix: "log/", * agency: agencyName, * }], * }); * ``` * ### Static Website Hosting * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * * const bucket = new huaweicloud.Obs.Bucket("b", { * acl: "public-read", * bucket: "obs-website-test.hashicorp.com", * website: { * errorDocument: "error.html", * indexDocument: "index.html", * routingRules: `[{ * "Condition": { * "KeyPrefixEquals": "docs/" * }, * "Redirect": { * "ReplaceKeyPrefixWith": "documents/" * } * }] * `, * }, * }); * ``` * ### Using CORS * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * * const bucket = new huaweicloud.Obs.Bucket("b", { * acl: "public-read", * bucket: "obs-website-test.hashicorp.com", * corsRules: [{ * allowedHeaders: ["*"], * allowedMethods: [ * "PUT", * "POST", * ], * allowedOrigins: ["https://obs-website-test.hashicorp.com"], * exposeHeaders: ["ETag"], * maxAgeSeconds: 3000, * }], * }); * ``` * ### Using object lifecycle * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * * const bucket = new huaweicloud.Obs.Bucket("bucket", { * acl: "private", * bucket: "my-bucket", * lifecycleRules: [ * { * abortIncompleteMultipartUploads: [{ * days: 360, * }], * enabled: true, * expirations: [{ * days: 365, * }], * name: "log", * prefix: "log/", * transitions: [ * { * days: 60, * storageClass: "WARM", * }, * { * days: 180, * storageClass: "COLD", * }, * ], * }, * { * enabled: true, * name: "tmp", * noncurrentVersionExpirations: [{ * days: 180, * }], * noncurrentVersionTransitions: [ * { * days: 30, * storageClass: "WARM", * }, * { * days: 60, * storageClass: "COLD", * }, * ], * }, * ], * versioning: true, * }); * ``` * ### using encryption * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * * const bucket = new huaweicloud.Obs.Bucket("bucket", { * acl: "private", * bucket: "my-tf-encryption-bucket", * encryption: true, * storageClass: "STANDARD", * tags: { * foo: "bar", * key: "value", * }, * }); * ``` * * ## Import * * OBS bucket can be imported using the `bucket`, e.g. bash * * ```sh * $ pulumi import huaweicloud:Obs/bucket:Bucket bucket <bucket-name> * ``` * * OBS bucket with S3 format bucket policy can be imported using the `bucket` and "s3" by a slash, e.g. bash * * ```sh * $ pulumi import huaweicloud:Obs/bucket:Bucket bucket_with_s3_policy <bucket-name>/s3 * ``` * * Note that the imported state may not be identical to your resource definition, due to some attributes missing from the API response. The missing attributes include `acl` and `force_destroy`. It is generally recommended running `terraform plan` after importing an OBS bucket. Also you can ignore changes as below. hcl resource "huaweicloud_obs_bucket" "bucket" { * * ... * * lifecycle { * * ignore_changes = [ * * acl, force_destroy, * * ] * * } } */ export declare class Bucket extends pulumi.CustomResource { /** * Get an existing Bucket 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?: BucketState, opts?: pulumi.CustomResourceOptions): Bucket; /** * Returns true if the given object is an instance of Bucket. 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 Bucket; /** * Specifies the ACL policy for a bucket. The predefined common policies are as follows: * "private", "public-read", "public-read-write" and "log-delivery-write". Defaults to `private`. */ readonly acl: pulumi.Output<string | undefined>; /** * Specifies the name of the bucket. Changing this parameter will create a new * resource. A bucket must be named according to the globally applied DNS naming regulations as follows: * + The name must be globally unique in OBS. * + The name must contain 3 to 63 characters. Only lowercase letters, digits, hyphens (-), and periods (.) are * allowed. * + The name cannot start or end with a period (.) or hyphen (-), and cannot contain two consecutive periods (.) or * contain a period (.) and a hyphen (-) adjacent to each other. * + The name cannot be an IP address. * + If the name contains any periods (.), a security certificate verification message may appear when you access the * bucket or its objects by entering a domain name. */ readonly bucket: pulumi.Output<string>; /** * The bucket domain name. Will be of format `bucketname.obs.region.myhuaweicloud.com`. */ readonly bucketDomainName: pulumi.Output<string>; /** * The OBS version of the bucket. */ readonly bucketVersion: pulumi.Output<string>; /** * A rule of Cross-Origin Resource Sharing (documented below). */ readonly corsRules: pulumi.Output<outputs.Obs.BucketCorsRule[] | undefined>; /** * Whether to enable default server-side encryption of the bucket. */ readonly encryption: pulumi.Output<boolean | undefined>; /** * Specifies the enterprise project id of the OBS bucket. * Defaults to `0`. */ readonly enterpriseProjectId: pulumi.Output<string>; /** * A boolean that indicates all objects should be deleted from the bucket, so that the * bucket can be destroyed without error. Default to `false`. */ readonly forceDestroy: pulumi.Output<boolean | undefined>; /** * Specifies the ID of a KMS key. If omitted, the default master key will be used. This * field is used only when `sseAlgorithm` value is **kms**. */ readonly kmsKeyId: pulumi.Output<string | undefined>; /** * Specifies the project ID to which the KMS key belongs. This field is valid * only when `kmsKeyId` is specified. */ readonly kmsKeyProjectId: pulumi.Output<string>; /** * A configuration of object lifecycle management (documented below). */ readonly lifecycleRules: pulumi.Output<outputs.Obs.BucketLifecycleRule[] | undefined>; /** * A settings of bucket logging (documented below). */ readonly loggings: pulumi.Output<outputs.Obs.BucketLogging[] | undefined>; /** * Whether enable the multi-AZ mode for the bucket. When the multi-AZ mode is * enabled, data in the bucket is duplicated and stored in multiple AZs. */ readonly multiAz: pulumi.Output<boolean>; /** * Whether enable a bucket as a parallel file system. Changing this will * create a new bucket. */ readonly parallelFs: pulumi.Output<boolean | undefined>; /** * Specifies the text of the bucket policy in JSON format. For more information about obs * format bucket policy, * see the [Developer Guide](https://support.huaweicloud.com/intl/en-us/perms-cfg-obs/obs_40_0004.html). */ readonly policy: pulumi.Output<string>; /** * Specifies the policy format, the supported values are *obs* and *s3*. Defaults * to *obs*. */ readonly policyFormat: pulumi.Output<string | undefined>; /** * Specifies bucket storage quota. Must be a positive integer in the unit of byte. The maximum * storage quota is 2<sup>63</sup> – 1 bytes. The default bucket storage quota is `0`, indicating that the bucket storage * quota is not limited. */ readonly quota: pulumi.Output<number | undefined>; /** * Specifies the region where this bucket will be created. If not specified, used * the region by the provider. Changing this will create a new bucket. */ readonly region: pulumi.Output<string>; /** * Specifies the mode of encryption algorithm. The valid values are: * + **kms**: Server-side encryption with keys hosted by KMS are used to encrypt your objects. * + **AES256**: Server-side encryption with keys managed by OBS are used to encrypt your objects. */ readonly sseAlgorithm: pulumi.Output<string>; /** * Specifies the storage class of the bucket. OBS provides three storage classes: * "STANDARD", "WARM" (Infrequent Access) and "COLD" (Archive). Defaults to `STANDARD`. */ readonly storageClass: pulumi.Output<string | undefined>; /** * The OBS storage info of the bucket. * The object structure is documented below. */ readonly storageInfos: pulumi.Output<outputs.Obs.BucketStorageInfo[]>; /** * A mapping of tags to assign to the bucket. Each tag is represented by one key-value pair. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Specifies the user domain names. The restriction requirements for this field * are as follows: * + Each value must meet the domain name rules. * + The maximum length of a domain name is 256 characters. * + A maximum of 100 custom domain names can be set for a bucket. * + A custom domain name can only be used by one bucket. * + Ensure the domain name has been licensed by the Ministry of Industry and Information Technology. * + The bound user domain names only support access over HTTP now. */ readonly userDomainNames: pulumi.Output<string[]>; /** * Whether enable versioning. Once you version-enable a bucket, it can never return to an * unversioned state. You can, however, suspend versioning on that bucket. */ readonly versioning: pulumi.Output<boolean | undefined>; /** * A website object (documented below). */ readonly website: pulumi.Output<outputs.Obs.BucketWebsite | undefined>; /** * Create a Bucket 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: BucketArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Bucket resources. */ export interface BucketState { /** * Specifies the ACL policy for a bucket. The predefined common policies are as follows: * "private", "public-read", "public-read-write" and "log-delivery-write". Defaults to `private`. */ acl?: pulumi.Input<string>; /** * Specifies the name of the bucket. Changing this parameter will create a new * resource. A bucket must be named according to the globally applied DNS naming regulations as follows: * + The name must be globally unique in OBS. * + The name must contain 3 to 63 characters. Only lowercase letters, digits, hyphens (-), and periods (.) are * allowed. * + The name cannot start or end with a period (.) or hyphen (-), and cannot contain two consecutive periods (.) or * contain a period (.) and a hyphen (-) adjacent to each other. * + The name cannot be an IP address. * + If the name contains any periods (.), a security certificate verification message may appear when you access the * bucket or its objects by entering a domain name. */ bucket?: pulumi.Input<string>; /** * The bucket domain name. Will be of format `bucketname.obs.region.myhuaweicloud.com`. */ bucketDomainName?: pulumi.Input<string>; /** * The OBS version of the bucket. */ bucketVersion?: pulumi.Input<string>; /** * A rule of Cross-Origin Resource Sharing (documented below). */ corsRules?: pulumi.Input<pulumi.Input<inputs.Obs.BucketCorsRule>[]>; /** * Whether to enable default server-side encryption of the bucket. */ encryption?: pulumi.Input<boolean>; /** * Specifies the enterprise project id of the OBS bucket. * Defaults to `0`. */ enterpriseProjectId?: pulumi.Input<string>; /** * A boolean that indicates all objects should be deleted from the bucket, so that the * bucket can be destroyed without error. Default to `false`. */ forceDestroy?: pulumi.Input<boolean>; /** * Specifies the ID of a KMS key. If omitted, the default master key will be used. This * field is used only when `sseAlgorithm` value is **kms**. */ kmsKeyId?: pulumi.Input<string>; /** * Specifies the project ID to which the KMS key belongs. This field is valid * only when `kmsKeyId` is specified. */ kmsKeyProjectId?: pulumi.Input<string>; /** * A configuration of object lifecycle management (documented below). */ lifecycleRules?: pulumi.Input<pulumi.Input<inputs.Obs.BucketLifecycleRule>[]>; /** * A settings of bucket logging (documented below). */ loggings?: pulumi.Input<pulumi.Input<inputs.Obs.BucketLogging>[]>; /** * Whether enable the multi-AZ mode for the bucket. When the multi-AZ mode is * enabled, data in the bucket is duplicated and stored in multiple AZs. */ multiAz?: pulumi.Input<boolean>; /** * Whether enable a bucket as a parallel file system. Changing this will * create a new bucket. */ parallelFs?: pulumi.Input<boolean>; /** * Specifies the text of the bucket policy in JSON format. For more information about obs * format bucket policy, * see the [Developer Guide](https://support.huaweicloud.com/intl/en-us/perms-cfg-obs/obs_40_0004.html). */ policy?: pulumi.Input<string>; /** * Specifies the policy format, the supported values are *obs* and *s3*. Defaults * to *obs*. */ policyFormat?: pulumi.Input<string>; /** * Specifies bucket storage quota. Must be a positive integer in the unit of byte. The maximum * storage quota is 2<sup>63</sup> – 1 bytes. The default bucket storage quota is `0`, indicating that the bucket storage * quota is not limited. */ quota?: pulumi.Input<number>; /** * Specifies the region where this bucket will be created. If not specified, used * the region by the provider. Changing this will create a new bucket. */ region?: pulumi.Input<string>; /** * Specifies the mode of encryption algorithm. The valid values are: * + **kms**: Server-side encryption with keys hosted by KMS are used to encrypt your objects. * + **AES256**: Server-side encryption with keys managed by OBS are used to encrypt your objects. */ sseAlgorithm?: pulumi.Input<string>; /** * Specifies the storage class of the bucket. OBS provides three storage classes: * "STANDARD", "WARM" (Infrequent Access) and "COLD" (Archive). Defaults to `STANDARD`. */ storageClass?: pulumi.Input<string>; /** * The OBS storage info of the bucket. * The object structure is documented below. */ storageInfos?: pulumi.Input<pulumi.Input<inputs.Obs.BucketStorageInfo>[]>; /** * A mapping of tags to assign to the bucket. Each tag is represented by one key-value pair. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Specifies the user domain names. The restriction requirements for this field * are as follows: * + Each value must meet the domain name rules. * + The maximum length of a domain name is 256 characters. * + A maximum of 100 custom domain names can be set for a bucket. * + A custom domain name can only be used by one bucket. * + Ensure the domain name has been licensed by the Ministry of Industry and Information Technology. * + The bound user domain names only support access over HTTP now. */ userDomainNames?: pulumi.Input<pulumi.Input<string>[]>; /** * Whether enable versioning. Once you version-enable a bucket, it can never return to an * unversioned state. You can, however, suspend versioning on that bucket. */ versioning?: pulumi.Input<boolean>; /** * A website object (documented below). */ website?: pulumi.Input<inputs.Obs.BucketWebsite>; } /** * The set of arguments for constructing a Bucket resource. */ export interface BucketArgs { /** * Specifies the ACL policy for a bucket. The predefined common policies are as follows: * "private", "public-read", "public-read-write" and "log-delivery-write". Defaults to `private`. */ acl?: pulumi.Input<string>; /** * Specifies the name of the bucket. Changing this parameter will create a new * resource. A bucket must be named according to the globally applied DNS naming regulations as follows: * + The name must be globally unique in OBS. * + The name must contain 3 to 63 characters. Only lowercase letters, digits, hyphens (-), and periods (.) are * allowed. * + The name cannot start or end with a period (.) or hyphen (-), and cannot contain two consecutive periods (.) or * contain a period (.) and a hyphen (-) adjacent to each other. * + The name cannot be an IP address. * + If the name contains any periods (.), a security certificate verification message may appear when you access the * bucket or its objects by entering a domain name. */ bucket: pulumi.Input<string>; /** * A rule of Cross-Origin Resource Sharing (documented below). */ corsRules?: pulumi.Input<pulumi.Input<inputs.Obs.BucketCorsRule>[]>; /** * Whether to enable default server-side encryption of the bucket. */ encryption?: pulumi.Input<boolean>; /** * Specifies the enterprise project id of the OBS bucket. * Defaults to `0`. */ enterpriseProjectId?: pulumi.Input<string>; /** * A boolean that indicates all objects should be deleted from the bucket, so that the * bucket can be destroyed without error. Default to `false`. */ forceDestroy?: pulumi.Input<boolean>; /** * Specifies the ID of a KMS key. If omitted, the default master key will be used. This * field is used only when `sseAlgorithm` value is **kms**. */ kmsKeyId?: pulumi.Input<string>; /** * Specifies the project ID to which the KMS key belongs. This field is valid * only when `kmsKeyId` is specified. */ kmsKeyProjectId?: pulumi.Input<string>; /** * A configuration of object lifecycle management (documented below). */ lifecycleRules?: pulumi.Input<pulumi.Input<inputs.Obs.BucketLifecycleRule>[]>; /** * A settings of bucket logging (documented below). */ loggings?: pulumi.Input<pulumi.Input<inputs.Obs.BucketLogging>[]>; /** * Whether enable the multi-AZ mode for the bucket. When the multi-AZ mode is * enabled, data in the bucket is duplicated and stored in multiple AZs. */ multiAz?: pulumi.Input<boolean>; /** * Whether enable a bucket as a parallel file system. Changing this will * create a new bucket. */ parallelFs?: pulumi.Input<boolean>; /** * Specifies the text of the bucket policy in JSON format. For more information about obs * format bucket policy, * see the [Developer Guide](https://support.huaweicloud.com/intl/en-us/perms-cfg-obs/obs_40_0004.html). */ policy?: pulumi.Input<string>; /** * Specifies the policy format, the supported values are *obs* and *s3*. Defaults * to *obs*. */ policyFormat?: pulumi.Input<string>; /** * Specifies bucket storage quota. Must be a positive integer in the unit of byte. The maximum * storage quota is 2<sup>63</sup> – 1 bytes. The default bucket storage quota is `0`, indicating that the bucket storage * quota is not limited. */ quota?: pulumi.Input<number>; /** * Specifies the region where this bucket will be created. If not specified, used * the region by the provider. Changing this will create a new bucket. */ region?: pulumi.Input<string>; /** * Specifies the mode of encryption algorithm. The valid values are: * + **kms**: Server-side encryption with keys hosted by KMS are used to encrypt your objects. * + **AES256**: Server-side encryption with keys managed by OBS are used to encrypt your objects. */ sseAlgorithm?: pulumi.Input<string>; /** * Specifies the storage class of the bucket. OBS provides three storage classes: * "STANDARD", "WARM" (Infrequent Access) and "COLD" (Archive). Defaults to `STANDARD`. */ storageClass?: pulumi.Input<string>; /** * A mapping of tags to assign to the bucket. Each tag is represented by one key-value pair. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Specifies the user domain names. The restriction requirements for this field * are as follows: * + Each value must meet the domain name rules. * + The maximum length of a domain name is 256 characters. * + A maximum of 100 custom domain names can be set for a bucket. * + A custom domain name can only be used by one bucket. * + Ensure the domain name has been licensed by the Ministry of Industry and Information Technology. * + The bound user domain names only support access over HTTP now. */ userDomainNames?: pulumi.Input<pulumi.Input<string>[]>; /** * Whether enable versioning. Once you version-enable a bucket, it can never return to an * unversioned state. You can, however, suspend versioning on that bucket. */ versioning?: pulumi.Input<boolean>; /** * A website object (documented below). */ website?: pulumi.Input<inputs.Obs.BucketWebsite>; }