AWS Classic

v5.16.0 published on Saturday, Sep 24, 2022 by Pulumi

BucketServerSideEncryptionConfigurationV2

Provides a S3 bucket server-side encryption configuration resource.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var mykey = new Aws.Kms.Key("mykey", new()
    {
        Description = "This key is used to encrypt bucket objects",
        DeletionWindowInDays = 10,
    });

    var mybucket = new Aws.S3.BucketV2("mybucket");

    var example = new Aws.S3.BucketServerSideEncryptionConfigurationV2("example", new()
    {
        Bucket = mybucket.Bucket,
        Rules = new[]
        {
            new Aws.S3.Inputs.BucketServerSideEncryptionConfigurationV2RuleArgs
            {
                ApplyServerSideEncryptionByDefault = new Aws.S3.Inputs.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs
                {
                    KmsMasterKeyId = mykey.Arn,
                    SseAlgorithm = "aws:kms",
                },
            },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/kms"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		mykey, err := kms.NewKey(ctx, "mykey", &kms.KeyArgs{
			Description:          pulumi.String("This key is used to encrypt bucket objects"),
			DeletionWindowInDays: pulumi.Int(10),
		})
		if err != nil {
			return err
		}
		mybucket, err := s3.NewBucketV2(ctx, "mybucket", nil)
		if err != nil {
			return err
		}
		_, err = s3.NewBucketServerSideEncryptionConfigurationV2(ctx, "example", &s3.BucketServerSideEncryptionConfigurationV2Args{
			Bucket: mybucket.Bucket,
			Rules: s3.BucketServerSideEncryptionConfigurationV2RuleArray{
				&s3.BucketServerSideEncryptionConfigurationV2RuleArgs{
					ApplyServerSideEncryptionByDefault: &s3.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs{
						KmsMasterKeyId: mykey.Arn,
						SseAlgorithm:   pulumi.String("aws:kms"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.kms.Key;
import com.pulumi.aws.kms.KeyArgs;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketServerSideEncryptionConfigurationV2;
import com.pulumi.aws.s3.BucketServerSideEncryptionConfigurationV2Args;
import com.pulumi.aws.s3.inputs.BucketServerSideEncryptionConfigurationV2RuleArgs;
import com.pulumi.aws.s3.inputs.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs;
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 mykey = new Key("mykey", KeyArgs.builder()        
            .description("This key is used to encrypt bucket objects")
            .deletionWindowInDays(10)
            .build());

        var mybucket = new BucketV2("mybucket");

        var example = new BucketServerSideEncryptionConfigurationV2("example", BucketServerSideEncryptionConfigurationV2Args.builder()        
            .bucket(mybucket.bucket())
            .rules(BucketServerSideEncryptionConfigurationV2RuleArgs.builder()
                .applyServerSideEncryptionByDefault(BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs.builder()
                    .kmsMasterKeyId(mykey.arn())
                    .sseAlgorithm("aws:kms")
                    .build())
                .build())
            .build());

    }
}
import pulumi
import pulumi_aws as aws

mykey = aws.kms.Key("mykey",
    description="This key is used to encrypt bucket objects",
    deletion_window_in_days=10)
mybucket = aws.s3.BucketV2("mybucket")
example = aws.s3.BucketServerSideEncryptionConfigurationV2("example",
    bucket=mybucket.bucket,
    rules=[aws.s3.BucketServerSideEncryptionConfigurationV2RuleArgs(
        apply_server_side_encryption_by_default=aws.s3.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs(
            kms_master_key_id=mykey.arn,
            sse_algorithm="aws:kms",
        ),
    )])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const mykey = new aws.kms.Key("mykey", {
    description: "This key is used to encrypt bucket objects",
    deletionWindowInDays: 10,
});
const mybucket = new aws.s3.BucketV2("mybucket", {});
const example = new aws.s3.BucketServerSideEncryptionConfigurationV2("example", {
    bucket: mybucket.bucket,
    rules: [{
        applyServerSideEncryptionByDefault: {
            kmsMasterKeyId: mykey.arn,
            sseAlgorithm: "aws:kms",
        },
    }],
});
resources:
  mykey:
    type: aws:kms:Key
    properties:
      description: This key is used to encrypt bucket objects
      deletionWindowInDays: 10
  mybucket:
    type: aws:s3:BucketV2
  example:
    type: aws:s3:BucketServerSideEncryptionConfigurationV2
    properties:
      bucket: ${mybucket.bucket}
      rules:
        - applyServerSideEncryptionByDefault:
            kmsMasterKeyId: ${mykey.arn}
            sseAlgorithm: aws:kms

Create a BucketServerSideEncryptionConfigurationV2 Resource

new BucketServerSideEncryptionConfigurationV2(name: string, args: BucketServerSideEncryptionConfigurationV2Args, opts?: CustomResourceOptions);
@overload
def BucketServerSideEncryptionConfigurationV2(resource_name: str,
                                              opts: Optional[ResourceOptions] = None,
                                              bucket: Optional[str] = None,
                                              expected_bucket_owner: Optional[str] = None,
                                              rules: Optional[Sequence[BucketServerSideEncryptionConfigurationV2RuleArgs]] = None)
@overload
def BucketServerSideEncryptionConfigurationV2(resource_name: str,
                                              args: BucketServerSideEncryptionConfigurationV2Args,
                                              opts: Optional[ResourceOptions] = None)
func NewBucketServerSideEncryptionConfigurationV2(ctx *Context, name string, args BucketServerSideEncryptionConfigurationV2Args, opts ...ResourceOption) (*BucketServerSideEncryptionConfigurationV2, error)
public BucketServerSideEncryptionConfigurationV2(string name, BucketServerSideEncryptionConfigurationV2Args args, CustomResourceOptions? opts = null)
public BucketServerSideEncryptionConfigurationV2(String name, BucketServerSideEncryptionConfigurationV2Args args)
public BucketServerSideEncryptionConfigurationV2(String name, BucketServerSideEncryptionConfigurationV2Args args, CustomResourceOptions options)
type: aws:s3:BucketServerSideEncryptionConfigurationV2
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args BucketServerSideEncryptionConfigurationV2Args
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args BucketServerSideEncryptionConfigurationV2Args
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args BucketServerSideEncryptionConfigurationV2Args
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args BucketServerSideEncryptionConfigurationV2Args
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args BucketServerSideEncryptionConfigurationV2Args
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

BucketServerSideEncryptionConfigurationV2 Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The BucketServerSideEncryptionConfigurationV2 resource accepts the following input properties:

Bucket string

The name of the bucket.

Rules List<BucketServerSideEncryptionConfigurationV2RuleArgs>

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

ExpectedBucketOwner string

The account ID of the expected bucket owner.

Bucket string

The name of the bucket.

Rules []BucketServerSideEncryptionConfigurationV2RuleArgs

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

ExpectedBucketOwner string

The account ID of the expected bucket owner.

bucket String

The name of the bucket.

rules List<BucketServerSideEncryptionConfigurationV2RuleArgs>

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

expectedBucketOwner String

The account ID of the expected bucket owner.

bucket string

The name of the bucket.

rules BucketServerSideEncryptionConfigurationV2RuleArgs[]

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

expectedBucketOwner string

The account ID of the expected bucket owner.

bucket str

The name of the bucket.

rules Sequence[BucketServerSideEncryptionConfigurationV2RuleArgs]

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

expected_bucket_owner str

The account ID of the expected bucket owner.

bucket String

The name of the bucket.

rules List<Property Map>

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

expectedBucketOwner String

The account ID of the expected bucket owner.

Outputs

All input properties are implicitly available as output properties. Additionally, the BucketServerSideEncryptionConfigurationV2 resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing BucketServerSideEncryptionConfigurationV2 Resource

Get an existing BucketServerSideEncryptionConfigurationV2 resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: BucketServerSideEncryptionConfigurationV2State, opts?: CustomResourceOptions): BucketServerSideEncryptionConfigurationV2
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        bucket: Optional[str] = None,
        expected_bucket_owner: Optional[str] = None,
        rules: Optional[Sequence[BucketServerSideEncryptionConfigurationV2RuleArgs]] = None) -> BucketServerSideEncryptionConfigurationV2
func GetBucketServerSideEncryptionConfigurationV2(ctx *Context, name string, id IDInput, state *BucketServerSideEncryptionConfigurationV2State, opts ...ResourceOption) (*BucketServerSideEncryptionConfigurationV2, error)
public static BucketServerSideEncryptionConfigurationV2 Get(string name, Input<string> id, BucketServerSideEncryptionConfigurationV2State? state, CustomResourceOptions? opts = null)
public static BucketServerSideEncryptionConfigurationV2 get(String name, Output<String> id, BucketServerSideEncryptionConfigurationV2State state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Bucket string

The name of the bucket.

ExpectedBucketOwner string

The account ID of the expected bucket owner.

Rules List<BucketServerSideEncryptionConfigurationV2RuleArgs>

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

Bucket string

The name of the bucket.

ExpectedBucketOwner string

The account ID of the expected bucket owner.

Rules []BucketServerSideEncryptionConfigurationV2RuleArgs

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

bucket String

The name of the bucket.

expectedBucketOwner String

The account ID of the expected bucket owner.

rules List<BucketServerSideEncryptionConfigurationV2RuleArgs>

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

bucket string

The name of the bucket.

expectedBucketOwner string

The account ID of the expected bucket owner.

rules BucketServerSideEncryptionConfigurationV2RuleArgs[]

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

bucket str

The name of the bucket.

expected_bucket_owner str

The account ID of the expected bucket owner.

rules Sequence[BucketServerSideEncryptionConfigurationV2RuleArgs]

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

bucket String

The name of the bucket.

expectedBucketOwner String

The account ID of the expected bucket owner.

rules List<Property Map>

Set of server-side encryption configuration rules. documented below. Currently, only a single rule is supported.

Supporting Types

BucketServerSideEncryptionConfigurationV2Rule

ApplyServerSideEncryptionByDefault BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefault

A single object for setting server-side encryption by default documented below

BucketKeyEnabled bool

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

ApplyServerSideEncryptionByDefault BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefault

A single object for setting server-side encryption by default documented below

BucketKeyEnabled bool

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

applyServerSideEncryptionByDefault BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefault

A single object for setting server-side encryption by default documented below

bucketKeyEnabled Boolean

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

applyServerSideEncryptionByDefault BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefault

A single object for setting server-side encryption by default documented below

bucketKeyEnabled boolean

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

apply_server_side_encryption_by_default BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefault

A single object for setting server-side encryption by default documented below

bucket_key_enabled bool

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

applyServerSideEncryptionByDefault Property Map

A single object for setting server-side encryption by default documented below

bucketKeyEnabled Boolean

Whether or not to use Amazon S3 Bucket Keys for SSE-KMS.

BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefault

SseAlgorithm string

The server-side encryption algorithm to use. Valid values are AES256 and aws:kms

KmsMasterKeyId string

The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.

SseAlgorithm string

The server-side encryption algorithm to use. Valid values are AES256 and aws:kms

KmsMasterKeyId string

The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.

sseAlgorithm String

The server-side encryption algorithm to use. Valid values are AES256 and aws:kms

kmsMasterKeyId String

The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.

sseAlgorithm string

The server-side encryption algorithm to use. Valid values are AES256 and aws:kms

kmsMasterKeyId string

The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.

sse_algorithm str

The server-side encryption algorithm to use. Valid values are AES256 and aws:kms

kms_master_key_id str

The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.

sseAlgorithm String

The server-side encryption algorithm to use. Valid values are AES256 and aws:kms

kmsMasterKeyId String

The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms.

Import

S3 bucket server-side encryption configuration can be imported in one of two ways. If the owner (account ID) of the source bucket is the same account used to configure the Terraform AWS Provider, the S3 server-side encryption configuration resource should be imported using the bucket e.g.,

 $ pulumi import aws:s3/bucketServerSideEncryptionConfigurationV2:BucketServerSideEncryptionConfigurationV2 example bucket-name

If the owner (account ID) of the source bucket differs from the account used to configure the Terraform AWS Provider, the S3 bucket server-side encryption configuration resource should be imported using the bucket and expected_bucket_owner separated by a comma (,) e.g.,

 $ pulumi import aws:s3/bucketServerSideEncryptionConfigurationV2:BucketServerSideEncryptionConfigurationV2 example bucket-name,123456789012

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.