AWS Classic
BucketVersioningV2
Import
S3 bucket versioning 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 bucket versioning resource should be imported using the bucket
e.g.,
$ 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 Terraform AWS Provider, the S3 bucket versioning resource should be imported using the bucket
and expected_bucket_owner
separated by a comma (,
) e.g.,
$ pulumi import aws:s3/bucketVersioningV2:BucketVersioningV2 example bucket-name,123456789012
Example Usage
With Versioning Enabled
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2", new Aws.S3.BucketV2Args
{
});
var exampleBucketAclV2 = new Aws.S3.BucketAclV2("exampleBucketAclV2", new Aws.S3.BucketAclV2Args
{
Bucket = exampleBucketV2.Id,
Acl = "private",
});
var versioningExample = new Aws.S3.BucketVersioningV2("versioningExample", new Aws.S3.BucketVersioningV2Args
{
Bucket = exampleBucketV2.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Enabled",
},
});
}
}
package main
import (
"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 {
exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", nil)
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "exampleBucketAclV2", &s3.BucketAclV2Args{
Bucket: exampleBucketV2.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketVersioningV2(ctx, "versioningExample", &s3.BucketVersioningV2Args{
Bucket: exampleBucketV2.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Enabled"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleBucketV2 = new BucketV2("exampleBucketV2");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(exampleBucketV2.id())
.acl("private")
.build());
var versioningExample = new BucketVersioningV2("versioningExample", BucketVersioningV2Args.builder()
.bucket(exampleBucketV2.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Enabled")
.build())
.build());
}
}
import pulumi
import pulumi_aws as aws
example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2")
example_bucket_acl_v2 = aws.s3.BucketAclV2("exampleBucketAclV2",
bucket=example_bucket_v2.id,
acl="private")
versioning_example = aws.s3.BucketVersioningV2("versioningExample",
bucket=example_bucket_v2.id,
versioning_configuration=aws.s3.BucketVersioningV2VersioningConfigurationArgs(
status="Enabled",
))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {});
const exampleBucketAclV2 = new aws.s3.BucketAclV2("exampleBucketAclV2", {
bucket: exampleBucketV2.id,
acl: "private",
});
const versioningExample = new aws.s3.BucketVersioningV2("versioningExample", {
bucket: exampleBucketV2.id,
versioningConfiguration: {
status: "Enabled",
},
});
resources:
exampleBucketV2:
type: aws:s3:BucketV2
exampleBucketAclV2:
type: aws:s3:BucketAclV2
properties:
bucket: ${exampleBucketV2.id}
acl: private
versioningExample:
type: aws:s3:BucketVersioningV2
properties:
bucket: ${exampleBucketV2.id}
versioningConfiguration:
status: Enabled
With Versioning Disabled
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2", new Aws.S3.BucketV2Args
{
});
var exampleBucketAclV2 = new Aws.S3.BucketAclV2("exampleBucketAclV2", new Aws.S3.BucketAclV2Args
{
Bucket = exampleBucketV2.Id,
Acl = "private",
});
var versioningExample = new Aws.S3.BucketVersioningV2("versioningExample", new Aws.S3.BucketVersioningV2Args
{
Bucket = exampleBucketV2.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Disabled",
},
});
}
}
package main
import (
"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 {
exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", nil)
if err != nil {
return err
}
_, err = s3.NewBucketAclV2(ctx, "exampleBucketAclV2", &s3.BucketAclV2Args{
Bucket: exampleBucketV2.ID(),
Acl: pulumi.String("private"),
})
if err != nil {
return err
}
_, err = s3.NewBucketVersioningV2(ctx, "versioningExample", &s3.BucketVersioningV2Args{
Bucket: exampleBucketV2.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Disabled"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleBucketV2 = new BucketV2("exampleBucketV2");
var exampleBucketAclV2 = new BucketAclV2("exampleBucketAclV2", BucketAclV2Args.builder()
.bucket(exampleBucketV2.id())
.acl("private")
.build());
var versioningExample = new BucketVersioningV2("versioningExample", BucketVersioningV2Args.builder()
.bucket(exampleBucketV2.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Disabled")
.build())
.build());
}
}
import pulumi
import pulumi_aws as aws
example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2")
example_bucket_acl_v2 = aws.s3.BucketAclV2("exampleBucketAclV2",
bucket=example_bucket_v2.id,
acl="private")
versioning_example = aws.s3.BucketVersioningV2("versioningExample",
bucket=example_bucket_v2.id,
versioning_configuration=aws.s3.BucketVersioningV2VersioningConfigurationArgs(
status="Disabled",
))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {});
const exampleBucketAclV2 = new aws.s3.BucketAclV2("exampleBucketAclV2", {
bucket: exampleBucketV2.id,
acl: "private",
});
const versioningExample = new aws.s3.BucketVersioningV2("versioningExample", {
bucket: exampleBucketV2.id,
versioningConfiguration: {
status: "Disabled",
},
});
resources:
exampleBucketV2:
type: aws:s3:BucketV2
exampleBucketAclV2:
type: aws:s3:BucketAclV2
properties:
bucket: ${exampleBucketV2.id}
acl: private
versioningExample:
type: aws:s3:BucketVersioningV2
properties:
bucket: ${exampleBucketV2.id}
versioningConfiguration:
status: Disabled
Object Dependency On Versioning
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2", new Aws.S3.BucketV2Args
{
});
var exampleBucketVersioningV2 = new Aws.S3.BucketVersioningV2("exampleBucketVersioningV2", new Aws.S3.BucketVersioningV2Args
{
Bucket = exampleBucketV2.Id,
VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
{
Status = "Enabled",
},
});
var exampleBucketObjectv2 = new Aws.S3.BucketObjectv2("exampleBucketObjectv2", new Aws.S3.BucketObjectv2Args
{
Bucket = exampleBucketVersioningV2.Bucket,
Key = "droeloe",
Source = new FileAsset("example.txt"),
});
}
}
package main
import (
"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 {
exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", nil)
if err != nil {
return err
}
exampleBucketVersioningV2, err := s3.NewBucketVersioningV2(ctx, "exampleBucketVersioningV2", &s3.BucketVersioningV2Args{
Bucket: exampleBucketV2.ID(),
VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
Status: pulumi.String("Enabled"),
},
})
if err != nil {
return err
}
_, err = s3.NewBucketObjectv2(ctx, "exampleBucketObjectv2", &s3.BucketObjectv2Args{
Bucket: exampleBucketVersioningV2.Bucket,
Key: pulumi.String("droeloe"),
Source: pulumi.NewFileAsset("example.txt"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleBucketV2 = new BucketV2("exampleBucketV2");
var exampleBucketVersioningV2 = new BucketVersioningV2("exampleBucketVersioningV2", BucketVersioningV2Args.builder()
.bucket(exampleBucketV2.id())
.versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
.status("Enabled")
.build())
.build());
var exampleBucketObjectv2 = new BucketObjectv2("exampleBucketObjectv2", BucketObjectv2Args.builder()
.bucket(exampleBucketVersioningV2.bucket())
.key("droeloe")
.source(new FileAsset("example.txt"))
.build());
}
}
import pulumi
import pulumi_aws as aws
example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2")
example_bucket_versioning_v2 = aws.s3.BucketVersioningV2("exampleBucketVersioningV2",
bucket=example_bucket_v2.id,
versioning_configuration=aws.s3.BucketVersioningV2VersioningConfigurationArgs(
status="Enabled",
))
example_bucket_objectv2 = aws.s3.BucketObjectv2("exampleBucketObjectv2",
bucket=example_bucket_versioning_v2.bucket,
key="droeloe",
source=pulumi.FileAsset("example.txt"))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {});
const exampleBucketVersioningV2 = new aws.s3.BucketVersioningV2("exampleBucketVersioningV2", {
bucket: exampleBucketV2.id,
versioningConfiguration: {
status: "Enabled",
},
});
const exampleBucketObjectv2 = new aws.s3.BucketObjectv2("exampleBucketObjectv2", {
bucket: exampleBucketVersioningV2.bucket,
key: "droeloe",
source: new pulumi.asset.FileAsset("example.txt"),
});
resources:
exampleBucketV2:
type: aws:s3:BucketV2
exampleBucketVersioningV2:
type: aws:s3:BucketVersioningV2
properties:
bucket: ${exampleBucketV2.id}
versioningConfiguration:
status: Enabled
exampleBucketObjectv2:
type: aws:s3:BucketObjectv2
properties:
bucket: ${exampleBucketVersioningV2.bucket}
key: droeloe
source:
Fn::FileAsset: example.txt
Create a BucketVersioningV2 Resource
new BucketVersioningV2(name: string, args: BucketVersioningV2Args, opts?: CustomResourceOptions);
@overload
def BucketVersioningV2(resource_name: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
expected_bucket_owner: Optional[str] = None,
mfa: Optional[str] = None,
versioning_configuration: Optional[BucketVersioningV2VersioningConfigurationArgs] = None)
@overload
def BucketVersioningV2(resource_name: str,
args: BucketVersioningV2Args,
opts: Optional[ResourceOptions] = None)
func NewBucketVersioningV2(ctx *Context, name string, args BucketVersioningV2Args, opts ...ResourceOption) (*BucketVersioningV2, error)
public BucketVersioningV2(string name, BucketVersioningV2Args args, CustomResourceOptions? opts = null)
public BucketVersioningV2(String name, BucketVersioningV2Args args)
public BucketVersioningV2(String name, BucketVersioningV2Args args, CustomResourceOptions options)
type: aws:s3:BucketVersioningV2
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketVersioningV2Args
- 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 BucketVersioningV2Args
- 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 BucketVersioningV2Args
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BucketVersioningV2Args
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BucketVersioningV2Args
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
BucketVersioningV2 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 BucketVersioningV2 resource accepts the following input properties:
- Bucket string
The name of the S3 bucket.
- Versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- Expected
Bucket stringOwner The account ID of the expected bucket owner.
- Mfa string
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- Bucket string
The name of the S3 bucket.
- Versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- Expected
Bucket stringOwner The account ID of the expected bucket owner.
- Mfa string
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- bucket String
The name of the S3 bucket.
- versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- expected
Bucket StringOwner The account ID of the expected bucket owner.
- mfa String
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- bucket string
The name of the S3 bucket.
- versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- expected
Bucket stringOwner The account ID of the expected bucket owner.
- mfa string
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- bucket str
The name of the S3 bucket.
- versioning_
configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- expected_
bucket_ strowner The account ID of the expected bucket owner.
- mfa str
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- bucket String
The name of the S3 bucket.
- versioning
Configuration Property Map Configuration block for the versioning parameters detailed below.
- expected
Bucket StringOwner The account ID of the expected bucket owner.
- mfa String
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
Outputs
All input properties are implicitly available as output properties. Additionally, the BucketVersioningV2 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 BucketVersioningV2 Resource
Get an existing BucketVersioningV2 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?: BucketVersioningV2State, opts?: CustomResourceOptions): BucketVersioningV2
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bucket: Optional[str] = None,
expected_bucket_owner: Optional[str] = None,
mfa: Optional[str] = None,
versioning_configuration: Optional[BucketVersioningV2VersioningConfigurationArgs] = None) -> BucketVersioningV2
func GetBucketVersioningV2(ctx *Context, name string, id IDInput, state *BucketVersioningV2State, opts ...ResourceOption) (*BucketVersioningV2, error)
public static BucketVersioningV2 Get(string name, Input<string> id, BucketVersioningV2State? state, CustomResourceOptions? opts = null)
public static BucketVersioningV2 get(String name, Output<String> id, BucketVersioningV2State 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.
- Bucket string
The name of the S3 bucket.
- Expected
Bucket stringOwner The account ID of the expected bucket owner.
- Mfa string
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- Versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- Bucket string
The name of the S3 bucket.
- Expected
Bucket stringOwner The account ID of the expected bucket owner.
- Mfa string
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- Versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- bucket String
The name of the S3 bucket.
- expected
Bucket StringOwner The account ID of the expected bucket owner.
- mfa String
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- bucket string
The name of the S3 bucket.
- expected
Bucket stringOwner The account ID of the expected bucket owner.
- mfa string
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- versioning
Configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- bucket str
The name of the S3 bucket.
- expected_
bucket_ strowner The account ID of the expected bucket owner.
- mfa str
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- versioning_
configuration BucketVersioning V2Versioning Configuration Args Configuration block for the versioning parameters detailed below.
- bucket String
The name of the S3 bucket.
- expected
Bucket StringOwner The account ID of the expected bucket owner.
- mfa String
The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.
- versioning
Configuration Property Map Configuration block for the versioning parameters detailed below.
Supporting Types
BucketVersioningV2VersioningConfiguration
- Status string
The versioning state of the bucket. Valid values:
Enabled
,Suspended
, orDisabled
.Disabled
should only be used when creating or importing resources that correspond to unversioned S3 buckets.- Mfa
Delete string Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values:
Enabled
orDisabled
.
- Status string
The versioning state of the bucket. Valid values:
Enabled
,Suspended
, orDisabled
.Disabled
should only be used when creating or importing resources that correspond to unversioned S3 buckets.- Mfa
Delete string Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values:
Enabled
orDisabled
.
- status String
The versioning state of the bucket. Valid values:
Enabled
,Suspended
, orDisabled
.Disabled
should only be used when creating or importing resources that correspond to unversioned S3 buckets.- mfa
Delete String Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values:
Enabled
orDisabled
.
- status string
The versioning state of the bucket. Valid values:
Enabled
,Suspended
, orDisabled
.Disabled
should only be used when creating or importing resources that correspond to unversioned S3 buckets.- mfa
Delete string Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values:
Enabled
orDisabled
.
- status str
The versioning state of the bucket. Valid values:
Enabled
,Suspended
, orDisabled
.Disabled
should only be used when creating or importing resources that correspond to unversioned S3 buckets.- mfa_
delete str Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values:
Enabled
orDisabled
.
- status String
The versioning state of the bucket. Valid values:
Enabled
,Suspended
, orDisabled
.Disabled
should only be used when creating or importing resources that correspond to unversioned S3 buckets.- mfa
Delete String Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values:
Enabled
orDisabled
.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.