UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

170 lines (169 loc) 5.97 kB
import * as pulumi from "@pulumi/pulumi"; /** * Attaches a policy to an OBS bucket resource. * * > **NOTE:** When creating or updating the OBS bucket policy, the original policy will be overwritten. * * ## Example Usage * ### Policy with OBS format * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const bucket = new huaweicloud.obs.Bucket("bucket", {bucket: "my-test-bucket"}); * const policy = new huaweicloud.obs.BucketPolicy("policy", { * bucket: bucket.id, * policy: `{ * "Statement": [ * { * "Sid": "AddPerm", * "Effect": "Allow", * "Principal": {"ID": "*"}, * "Action": ["GetObject"], * "Resource": "my-test-bucket/*" * } * ] * } * `, * }); * ``` * ### Policy with S3 format * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const bucket = new huaweicloud.obs.Bucket("bucket", {bucket: "my-test-bucket"}); * const s3Policy = new huaweicloud.obs.BucketPolicy("s3Policy", { * bucket: bucket.id, * policyFormat: "s3", * policy: `{ * "Version": "2008-10-17", * "Id": "MYBUCKETPOLICY", * "Statement": [ * { * "Sid": "IPAllow", * "Effect": "Allow", * "Principal": "*", * "Action": "s3:*", * "Resource": "arn:aws:s3:::my-test-bucket/*", * "Condition": { * "IpAddress": {"aws:SourceIp": "8.8.8.8/32"} * } * } * ] * } * `, * }); * ``` * * ## Import * * OBS format bucket policy can be imported using the `<bucket>`, e.g. bash * * ```sh * $ pulumi import huaweicloud:Obs/bucketPolicy:BucketPolicy policy <bucket-name> * ``` * * S3 format bucket policy can be imported using the `<bucket>` and "s3" by a slash, e.g. bash * * ```sh * $ pulumi import huaweicloud:Obs/bucketPolicy:BucketPolicy s3_policy <bucket-name>/s3 * ``` */ export declare class BucketPolicy extends pulumi.CustomResource { /** * Get an existing BucketPolicy 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?: BucketPolicyState, opts?: pulumi.CustomResourceOptions): BucketPolicy; /** * Returns true if the given object is an instance of BucketPolicy. 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 BucketPolicy; /** * Specifies the name of the bucket to which to apply the policy. */ readonly bucket: pulumi.Output<string>; /** * 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>; /** * The region in which to create the OBS bucket policy resource. If omitted, the * provider-level region will be used. Changing this creates a new OBS bucket policy resource. */ readonly region: pulumi.Output<string>; /** * Create a BucketPolicy 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: BucketPolicyArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering BucketPolicy resources. */ export interface BucketPolicyState { /** * Specifies the name of the bucket to which to apply the policy. */ bucket?: pulumi.Input<string>; /** * 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>; /** * The region in which to create the OBS bucket policy resource. If omitted, the * provider-level region will be used. Changing this creates a new OBS bucket policy resource. */ region?: pulumi.Input<string>; } /** * The set of arguments for constructing a BucketPolicy resource. */ export interface BucketPolicyArgs { /** * Specifies the name of the bucket to which to apply the policy. */ bucket: pulumi.Input<string>; /** * 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>; /** * The region in which to create the OBS bucket policy resource. If omitted, the * provider-level region will be used. Changing this creates a new OBS bucket policy resource. */ region?: pulumi.Input<string>; }