com.pulumi.aws.s3control.kotlin.BucketPolicy.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-aws-kotlin Show documentation
Show all versions of pulumi-aws-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.aws.s3control.kotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [BucketPolicy].
*/
@PulumiTagMarker
public class BucketPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: BucketPolicyArgs = BucketPolicyArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend BucketPolicyArgsBuilder.() -> Unit) {
val builder = BucketPolicyArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): BucketPolicy {
val builtJavaResource = com.pulumi.aws.s3control.BucketPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return BucketPolicy(builtJavaResource)
}
}
/**
* Provides a resource to manage an S3 Control Bucket Policy.
* > This functionality is for managing [S3 on Outposts](https://docs.aws.amazon.com/AmazonS3/latest/dev/S3onOutposts.html). To manage S3 Bucket Policies in an AWS Partition, see the `aws.s3.BucketPolicy` resource.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* const example = new aws.s3control.BucketPolicy("example", {
* bucket: exampleAwsS3controlBucket.arn,
* policy: JSON.stringify({
* Id: "testBucketPolicy",
* Statement: [{
* Action: "s3-outposts:PutBucketLifecycleConfiguration",
* Effect: "Deny",
* Principal: {
* AWS: "*",
* },
* Resource: exampleAwsS3controlBucket.arn,
* Sid: "statement1",
* }],
* Version: "2012-10-17",
* }),
* });
* ```
* ```python
* import pulumi
* import json
* import pulumi_aws as aws
* example = aws.s3control.BucketPolicy("example",
* bucket=example_aws_s3control_bucket["arn"],
* policy=json.dumps({
* "Id": "testBucketPolicy",
* "Statement": [{
* "Action": "s3-outposts:PutBucketLifecycleConfiguration",
* "Effect": "Deny",
* "Principal": {
* "AWS": "*",
* },
* "Resource": example_aws_s3control_bucket["arn"],
* "Sid": "statement1",
* }],
* "Version": "2012-10-17",
* }))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using System.Text.Json;
* using Pulumi;
* using Aws = Pulumi.Aws;
* return await Deployment.RunAsync(() =>
* {
* var example = new Aws.S3Control.BucketPolicy("example", new()
* {
* Bucket = exampleAwsS3controlBucket.Arn,
* Policy = JsonSerializer.Serialize(new Dictionary
* {
* ["Id"] = "testBucketPolicy",
* ["Statement"] = new[]
* {
* new Dictionary
* {
* ["Action"] = "s3-outposts:PutBucketLifecycleConfiguration",
* ["Effect"] = "Deny",
* ["Principal"] = new Dictionary
* {
* ["AWS"] = "*",
* },
* ["Resource"] = exampleAwsS3controlBucket.Arn,
* ["Sid"] = "statement1",
* },
* },
* ["Version"] = "2012-10-17",
* }),
* });
* });
* ```
* ```go
* package main
* import (
* "encoding/json"
* "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3control"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* tmpJSON0, err := json.Marshal(map[string]interface{}{
* "Id": "testBucketPolicy",
* "Statement": []map[string]interface{}{
* map[string]interface{}{
* "Action": "s3-outposts:PutBucketLifecycleConfiguration",
* "Effect": "Deny",
* "Principal": map[string]interface{}{
* "AWS": "*",
* },
* "Resource": exampleAwsS3controlBucket.Arn,
* "Sid": "statement1",
* },
* },
* "Version": "2012-10-17",
* })
* if err != nil {
* return err
* }
* json0 := string(tmpJSON0)
* _, err = s3control.NewBucketPolicy(ctx, "example", &s3control.BucketPolicyArgs{
* Bucket: pulumi.Any(exampleAwsS3controlBucket.Arn),
* Policy: pulumi.String(json0),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.aws.s3control.BucketPolicy;
* import com.pulumi.aws.s3control.BucketPolicyArgs;
* import static com.pulumi.codegen.internal.Serialization.*;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var example = new BucketPolicy("example", BucketPolicyArgs.builder()
* .bucket(exampleAwsS3controlBucket.arn())
* .policy(serializeJson(
* jsonObject(
* jsonProperty("Id", "testBucketPolicy"),
* jsonProperty("Statement", jsonArray(jsonObject(
* jsonProperty("Action", "s3-outposts:PutBucketLifecycleConfiguration"),
* jsonProperty("Effect", "Deny"),
* jsonProperty("Principal", jsonObject(
* jsonProperty("AWS", "*")
* )),
* jsonProperty("Resource", exampleAwsS3controlBucket.arn()),
* jsonProperty("Sid", "statement1")
* ))),
* jsonProperty("Version", "2012-10-17")
* )))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: aws:s3control:BucketPolicy
* properties:
* bucket: ${exampleAwsS3controlBucket.arn}
* policy:
* fn::toJSON:
* Id: testBucketPolicy
* Statement:
* - Action: s3-outposts:PutBucketLifecycleConfiguration
* Effect: Deny
* Principal:
* AWS: '*'
* Resource: ${exampleAwsS3controlBucket.arn}
* Sid: statement1
* Version: 2012-10-17
* ```
*
* ## Import
* Using `pulumi import`, import S3 Control Bucket Policies using the Amazon Resource Name (ARN). For example:
* ```sh
* $ pulumi import aws:s3control/bucketPolicy:BucketPolicy example arn:aws:s3-outposts:us-east-1:123456789012:outpost/op-12345678/bucket/example
* ```
*/
public class BucketPolicy internal constructor(
override val javaResource: com.pulumi.aws.s3control.BucketPolicy,
) : KotlinCustomResource(javaResource, BucketPolicyMapper) {
/**
* Amazon Resource Name (ARN) of the bucket.
*/
public val bucket: Output
get() = javaResource.bucket().applyValue({ args0 -> args0 })
/**
* JSON string of the resource policy.
*/
public val policy: Output
get() = javaResource.policy().applyValue({ args0 -> args0 })
}
public object BucketPolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.aws.s3control.BucketPolicy::class == javaResource::class
override fun map(javaResource: Resource): BucketPolicy = BucketPolicy(
javaResource as
com.pulumi.aws.s3control.BucketPolicy,
)
}
/**
* @see [BucketPolicy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [BucketPolicy].
*/
public suspend fun bucketPolicy(
name: String,
block: suspend BucketPolicyResourceBuilder.() -> Unit,
): BucketPolicy {
val builder = BucketPolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [BucketPolicy].
* @param name The _unique_ name of the resulting resource.
*/
public fun bucketPolicy(name: String): BucketPolicy {
val builder = BucketPolicyResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy