@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
134 lines • 4.78 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.BucketPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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
* ```
*/
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, id, state, opts) {
return new BucketPolicy(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === BucketPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state ? state.bucket : undefined;
resourceInputs["policy"] = state ? state.policy : undefined;
resourceInputs["policyFormat"] = state ? state.policyFormat : undefined;
resourceInputs["region"] = state ? state.region : undefined;
}
else {
const args = argsOrState;
if ((!args || args.bucket === undefined) && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
if ((!args || args.policy === undefined) && !opts.urn) {
throw new Error("Missing required property 'policy'");
}
resourceInputs["bucket"] = args ? args.bucket : undefined;
resourceInputs["policy"] = args ? args.policy : undefined;
resourceInputs["policyFormat"] = args ? args.policyFormat : undefined;
resourceInputs["region"] = args ? args.region : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BucketPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.BucketPolicy = BucketPolicy;
/** @internal */
BucketPolicy.__pulumiType = 'huaweicloud:Obs/bucketPolicy:BucketPolicy';
//# sourceMappingURL=bucketPolicy.js.map