BucketVersioningV2Args

data class BucketVersioningV2Args(val bucket: Output<String>? = null, val expectedBucketOwner: Output<String>? = null, val mfa: Output<String>? = null, val versioningConfiguration: Output<BucketVersioningV2VersioningConfigurationArgs>? = null) : ConvertibleToJava<BucketVersioningV2Args>

Provides a resource for controlling versioning on an S3 bucket. Deleting this resource will either suspend versioning on the associated S3 bucket or simply remove the resource from state if the associated S3 bucket is unversioned. For more information, see How S3 versioning works.

NOTE: If you are enabling versioning on the bucket for the first time, AWS recommends that you wait for 15 minutes after enabling versioning before issuing write operations (PUT or DELETE) on objects in the bucket. This resource cannot be used with S3 directory buckets.

Example Usage

With Versioning Enabled

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "example-bucket"});
const exampleBucketAclV2 = new aws.s3.BucketAclV2("example", {
bucket: example.id,
acl: "private",
});
const versioningExample = new aws.s3.BucketVersioningV2("versioning_example", {
bucket: example.id,
versioningConfiguration: {
status: "Enabled",
},
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="example-bucket")
example_bucket_acl_v2 = aws.s3.BucketAclV2("example",
bucket=example.id,
acl="private")
versioning_example = aws.s3.BucketVersioningV2("versioning_example",
bucket=example.id,
versioning_configuration={
"status": "Enabled",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "example-bucket",
});
var exampleBucketAclV2 = new Aws.S3.BucketAclV2("example", new()
{
Bucket = example.Id,
Acl = "private",
});
var versioningExample = new Aws.S3.BucketVersioningV2("versioning_example", new()
{
Bucket = example.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Enabled",
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("example-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: example.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketVersioningV2(ctx, "versioning_example", &s3.BucketVersioningV2Args{
Bucket: example.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Enabled"),
},
})
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.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketVersioningV2;
import com.pulumi.aws.s3.BucketVersioningV2Args;
import com.pulumi.aws.s3.inputs.BucketVersioningV2VersioningConfigurationArgs;
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 BucketV2("example", BucketV2Args.builder()
.bucket("example-bucket")
.build());
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(example.id())
.acl("private")
.build());
var versioningExample = new BucketVersioningV2("versioningExample", BucketVersioningV2Args.builder()
.bucket(example.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Enabled")
.build())
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: example-bucket
exampleBucketAclV2:
type: aws:s3:BucketAclV2
name: example
properties:
bucket: ${example.id}
acl: private
versioningExample:
type: aws:s3:BucketVersioningV2
name: versioning_example
properties:
bucket: ${example.id}
versioningConfiguration:
status: Enabled

With Versioning Disabled

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "example-bucket"});
const exampleBucketAclV2 = new aws.s3.BucketAclV2("example", {
bucket: example.id,
acl: "private",
});
const versioningExample = new aws.s3.BucketVersioningV2("versioning_example", {
bucket: example.id,
versioningConfiguration: {
status: "Disabled",
},
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="example-bucket")
example_bucket_acl_v2 = aws.s3.BucketAclV2("example",
bucket=example.id,
acl="private")
versioning_example = aws.s3.BucketVersioningV2("versioning_example",
bucket=example.id,
versioning_configuration={
"status": "Disabled",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "example-bucket",
});
var exampleBucketAclV2 = new Aws.S3.BucketAclV2("example", new()
{
Bucket = example.Id,
Acl = "private",
});
var versioningExample = new Aws.S3.BucketVersioningV2("versioning_example", new()
{
Bucket = example.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Disabled",
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("example-bucket"),
})
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "example", &s3.BucketAclV2Args{
Bucket: example.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketVersioningV2(ctx, "versioning_example", &s3.BucketVersioningV2Args{
Bucket: example.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Disabled"),
},
})
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.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketAclV2;
import com.pulumi.aws.s3.BucketAclV2Args;
import com.pulumi.aws.s3.BucketVersioningV2;
import com.pulumi.aws.s3.BucketVersioningV2Args;
import com.pulumi.aws.s3.inputs.BucketVersioningV2VersioningConfigurationArgs;
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 BucketV2("example", BucketV2Args.builder()
.bucket("example-bucket")
.build());
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(example.id())
.acl("private")
.build());
var versioningExample = new BucketVersioningV2("versioningExample", BucketVersioningV2Args.builder()
.bucket(example.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Disabled")
.build())
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: example-bucket
exampleBucketAclV2:
type: aws:s3:BucketAclV2
name: example
properties:
bucket: ${example.id}
acl: private
versioningExample:
type: aws:s3:BucketVersioningV2
name: versioning_example
properties:
bucket: ${example.id}
versioningConfiguration:
status: Disabled

Object Dependency On Versioning

When you create an object whose version_id you need and an aws.s3.BucketVersioningV2 resource in the same configuration, you are more likely to have success by ensuring the s3_object depends either implicitly (see below) or explicitly (i.e., using depends_on = [aws_s3_bucket_versioning&#46;example]) on the aws.s3.BucketVersioningV2 resource.

NOTE: For critical and/or production S3 objects, do not create a bucket, enable versioning, and create an object in the bucket within the same configuration. Doing so will not allow the AWS-recommended 15 minutes between enabling versioning and writing to the bucket. This example shows the aws_s3_object.example depending implicitly on the versioning resource through the reference to aws_s3_bucket_versioning.example.bucket to define bucket:

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.s3.BucketV2("example", {bucket: "yotto"});
const exampleBucketVersioningV2 = new aws.s3.BucketVersioningV2("example", {
bucket: example.id,
versioningConfiguration: {
status: "Enabled",
},
});
const exampleBucketObjectv2 = new aws.s3.BucketObjectv2("example", {
bucket: exampleBucketVersioningV2.id,
key: "droeloe",
source: new pulumi.asset.FileAsset("example.txt"),
});
import pulumi
import pulumi_aws as aws
example = aws.s3.BucketV2("example", bucket="yotto")
example_bucket_versioning_v2 = aws.s3.BucketVersioningV2("example",
bucket=example.id,
versioning_configuration={
"status": "Enabled",
})
example_bucket_objectv2 = aws.s3.BucketObjectv2("example",
bucket=example_bucket_versioning_v2.id,
key="droeloe",
source=pulumi.FileAsset("example.txt"))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.S3.BucketV2("example", new()
{
Bucket = "yotto",
});
var exampleBucketVersioningV2 = new Aws.S3.BucketVersioningV2("example", new()
{
Bucket = example.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Enabled",
},
});
var exampleBucketObjectv2 = new Aws.S3.BucketObjectv2("example", new()
{
Bucket = exampleBucketVersioningV2.Id,
Key = "droeloe",
Source = new FileAsset("example.txt"),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
Bucket: pulumi.String("yotto"),
})
if err != nil {
return err
}
exampleBucketVersioningV2, err := s3.NewBucketVersioningV2(ctx, "example", &s3.BucketVersioningV2Args{
Bucket: example.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Enabled"),
},
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "example", &s3.BucketObjectv2Args{
Bucket: exampleBucketVersioningV2.ID(),
Key: pulumi.String("droeloe"),
Source: pulumi.NewFileAsset("example.txt"),
})
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.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketVersioningV2;
import com.pulumi.aws.s3.BucketVersioningV2Args;
import com.pulumi.aws.s3.inputs.BucketVersioningV2VersioningConfigurationArgs;
import com.pulumi.aws.s3.BucketObjectv2;
import com.pulumi.aws.s3.BucketObjectv2Args;
import com.pulumi.asset.FileAsset;
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 BucketV2("example", BucketV2Args.builder()
.bucket("yotto")
.build());
var exampleBucketVersioningV2 = new BucketVersioningV2("exampleBucketVersioningV2", BucketVersioningV2Args.builder()
.bucket(example.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Enabled")
.build())
.build());
var exampleBucketObjectv2 = new BucketObjectv2("exampleBucketObjectv2", BucketObjectv2Args.builder()
.bucket(exampleBucketVersioningV2.id())
.key("droeloe")
.source(new FileAsset("example.txt"))
.build());
}
}
resources:
example:
type: aws:s3:BucketV2
properties:
bucket: yotto
exampleBucketVersioningV2:
type: aws:s3:BucketVersioningV2
name: example
properties:
bucket: ${example.id}
versioningConfiguration:
status: Enabled
exampleBucketObjectv2:
type: aws:s3:BucketObjectv2
name: example
properties:
bucket: ${exampleBucketVersioningV2.id}
key: droeloe
source:
fn::FileAsset: example.txt

Import

If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the bucket and expected_bucket_owner separated by a comma (,): Using pulumi import to import S3 bucket versioning using the bucket or using the bucket and expected_bucket_owner separated by a comma (,). For example: If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the bucket:

$ pulumi import aws:s3/bucketVersioningV2:BucketVersioningV2 example bucket-name

If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the bucket and expected_bucket_owner separated by a comma (,):

$ pulumi import aws:s3/bucketVersioningV2:BucketVersioningV2 example bucket-name,123456789012

Constructors

Link copied to clipboard
constructor(bucket: Output<String>? = null, expectedBucketOwner: Output<String>? = null, mfa: Output<String>? = null, versioningConfiguration: Output<BucketVersioningV2VersioningConfigurationArgs>? = null)

Properties

Link copied to clipboard
val bucket: Output<String>? = null

Name of the S3 bucket.

Link copied to clipboard
val expectedBucketOwner: Output<String>? = null

Account ID of the expected bucket owner.

Link copied to clipboard
val mfa: Output<String>? = null

Concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.

Link copied to clipboard

Configuration block for the versioning parameters. See below.

Functions

Link copied to clipboard
open override fun toJava(): BucketVersioningV2Args