Skip to content

Commit

Permalink
Update Bucket references to BucketV2 (#13011)
Browse files Browse the repository at this point in the history
Update references to aws.s3.Bucket with aws.s3.BucketV2, just as we would like our users to do.
  • Loading branch information
t0yv0 authored Nov 9, 2024
1 parent a387477 commit b256390
Show file tree
Hide file tree
Showing 67 changed files with 428 additions and 221 deletions.
2 changes: 1 addition & 1 deletion BLOGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ There are a couple of ways to do [syntax highlighing](https://gohugo.io/content-

<pre>
```typescript
let bucket = new aws.s3.Bucket("stuff");
let bucket = new aws.s3.BucketV2("stuff");
...
```
</pre>
Expand Down
2 changes: 1 addition & 1 deletion content/challenge/one-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Run `pulumi up`. You will first be presented with a preview of the changes to oc
+ ├─ aws:lambda:Function fn create
+ └─ aws-apigateway:index:RestAPI api create
+ ├─ aws:iam:Role api4c238266 create
+ ├─ aws:s3:Bucket api create
+ ├─ aws:s3:BucketV2 api create
+ ├─ aws:iam:RolePolicyAttachment api4c238266 create
+ ├─ aws:apigateway:RestApi api create
+ ├─ aws:s3:BucketObject api4c238266/index.html create
Expand Down
19 changes: 6 additions & 13 deletions content/docs/iac/adopting-pulumi/import/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Both approaches allow you to adopt and begin managing existing cloud resources w

Import uses the selected stack's configured [provider](/docs/concepts/resources/providers/) to look up the desired resource in the cloud provider, read its current configuration, and add the resource to the stack to bring it under management by Pulumi from that point forward. For this, it requires two pieces of information:

* The _type_ of cloud resource to import --- either as a type _token_ (a string that uniquely identifies a Pulumi resource type) when using the CLI or as a resource declaration when importing in code. The type token of an Amazon S3 Bucket resource, for example, is `aws:s3/bucket:Bucket`.
* The _type_ of cloud resource to import --- either as a type _token_ (a string that uniquely identifies a Pulumi resource type) when using the CLI or as a resource declaration when importing in code. The type token of an Amazon S3 Bucket resource, for example, is `aws:s3/bucketv2:BucketV2`.

* The _name_ and _value_ of the property to use for the resource lookup. Lookup properties vary by resource. For an Amazon S3 bucket, the property used for lookup is [`bucket`](/registry/packages/aws/api-docs/s3/bucket/#bucket_nodejs), so the value to use for the lookup would be the bucket's globally unique name. For an Amazon VPC, however, the property used for lookup is [`id`](/registry/packages/aws/api-docs/ec2/vpc/#id_nodejs), so the value to use for it would be its AWS-assigned unique identifier.

Expand All @@ -64,7 +64,7 @@ $ pulumi import <type> <name> <id>

* The first argument, `type`, is the Pulumi type token to use for the imported resource.

As mentioned in [Where to find the type token and lookup property](#how-import-works), you'll find the type token for a given resource by navigating to the Import section of the resource's API documentation in the [Pulumi Registry](/registry/). For example, the type token of an [Amazon S3 Bucket](/registry/packages/aws/api-docs/s3/bucket/#import) resource, for example, is `aws:s3/bucket:Bucket`.
As mentioned in [Where to find the type token and lookup property](#how-import-works), you'll find the type token for a given resource by navigating to the Import section of the resource's API documentation in the [Pulumi Registry](/registry/). For example, the type token of an [Amazon S3 Bucket](/registry/packages/aws/api-docs/s3/bucketv2/#import) resource, for example, is `aws:s3/bucketv2:BucketV2`.

* The second argument, `name`, is the [resource name](/docs/concepts/resources/names) to apply to the resource once it's imported. The generated code will use this name for the resource declaration (the first parameter in any resource), so like all Pulumi resource names, it must be unique among all resources for this type within the scope of the containing project. (That is, you may have an S3 bucket and a VPC named `foo`, but you cannot have two S3 buckets named `foo`.)

Expand All @@ -77,13 +77,13 @@ For help identifying a resource's type token and lookup property, see [Where to
In this example, a previously provisioned Amazon S3 bucket named `company-infra-logs` is imported into a Pulumi stack named `dev` (the currently [selected](/docs/cli/commands/pulumi_stack_select/) stack) and given a resource name of `infra-logs`:

```bash
$ pulumi import aws:s3/bucket:Bucket infra-logs company-infra-logs
$ pulumi import aws:s3/bucketv2:BucketV2 infra-logs company-infra-logs

Previewing import (dev)

Type Name Plan
+ pulumi:pulumi:Stack dev create
= └─ aws:s3:Bucket my-bucket import
= └─ aws:s3:BucketV2 my-bucket import

Resources:
+ 1 to create
Expand All @@ -105,7 +105,7 @@ Importing (dev)
Type Name Status
+ pulumi:pulumi:Stack dev created (3s)
= └─ aws:s3:Bucket my-bucket imported (1s)
= └─ aws:s3:BucketV2 my-bucket imported (1s)
Resources:
+ 1 created
Expand All @@ -124,18 +124,11 @@ the destroy will take effect.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const my_bucket = new aws.s3.Bucket("infra-logs", {
const my_bucket = new aws.s3.BucketV2("infra-logs", {
arn: "arn:aws:s3:::company-infra-logs",
bucket: "company-infra-logs",
hostedZoneId: "Z3BJ4Q6RFIQJ6N",
requestPayer: "BucketOwner",
serverSideEncryptionConfiguration: {
rule: {
applyServerSideEncryptionByDefault: {
sseAlgorithm: "AES256",
},
},
},
}, {
protect: true,
});
Expand Down
2 changes: 1 addition & 1 deletion content/docs/iac/clouds/aws/guides/more.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This example provisions an S3 bucket and an Athena database, then creates a name
```typescript
import * as aws from "@pulumi/aws";

const databaseBucket = new aws.s3.Bucket("mydatabasebucket", {
const databaseBucket = new aws.s3.BucketV2("mydatabasebucket", {
forceDestroy: true,
});

Expand Down
2 changes: 1 addition & 1 deletion content/docs/iac/concepts/projects/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The following are other examples of `Pulumi.yaml` files that define project conf
runtime: yaml
resources:
bucket:
type: aws:s3:Bucket
type: aws:s3:BucketV2
```

For more information on valid Pulumi project metadata, see the [Pulumi.yaml reference](/docs/reference/pulumi-yaml/).
Expand Down
18 changes: 9 additions & 9 deletions content/docs/iac/concepts/resources/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,48 +142,48 @@ This example demonstrates both the naming convention and how to designate the co
{{% choosable language javascript %}}

```javascript
let bucket = new aws.s3.Bucket(`${name}-bucket`,
let bucket = new aws.s3.BucketV2(`${name}-bucket`,
{/*...*/}, { parent: this });
```

{{% /choosable %}}
{{% choosable language typescript %}}

```typescript
let bucket = new aws.s3.Bucket(`${name}-bucket`,
let bucket = new aws.s3.BucketV2(`${name}-bucket`,
{/*...*/}, { parent: this });
```

{{% /choosable %}}
{{% choosable language python %}}

```python
bucket = s3.Bucket(f"{name}-bucket",
bucket = s3.BucketV2(f"{name}-bucket",
opts=pulumi.ResourceOptions(parent=self))
```

{{% /choosable %}}
{{% choosable language go %}}

```go
bucket, err := s3.NewBucket(ctx, fmt.Sprintf("%s-bucket", name),
&s3.BucketArgs{ /*...*/ }, pulumi.Parent(myComponent))
bucket, err := s3.NewBucketV2(ctx, fmt.Sprintf("%s-bucket", name),
&s3.BucketV2Args{ /*...*/ }, pulumi.Parent(myComponent))
```

{{% /choosable %}}
{{% choosable language csharp %}}

```csharp
var bucket = new Aws.S3.Bucket($"{name}-bucket",
new Aws.S3.BucketArgs(/*...*/), new CustomResourceOptions { Parent = this });
var bucket = new Aws.S3.BucketV2($"{name}-bucket",
new Aws.S3.BucketV2Args(/*...*/), new CustomResourceOptions { Parent = this });
```

{{% /choosable %}}
{{% choosable language java %}}

```java
var bucket = new Bucket(String.format("%s-bucket", name),
BucketArgs.builder()
var bucket = new BucketV2(String.format("%s-bucket", name),
BucketV2Args.builder()
...
.build(),
CustomResourceOptions.builder()
Expand Down
16 changes: 8 additions & 8 deletions content/docs/iac/concepts/resources/names.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ resources:
{{< /chooser >}}
If the `name` property is not available on a resource, consult the [Registry](/registry/) for the specific resource you are creating. Some resources use a different property to override auto-naming. For instance, the `aws.s3.Bucket` type uses the property `bucket` instead of name. Other resources, such as `aws.kms.Key`, do not have physical names and use other auto-generated IDs to uniquely identify them.
If the `name` property is not available on a resource, consult the [Registry](/registry/) for the specific resource you are creating. Some resources use a different property to override auto-naming. For instance, the `aws.s3.BucketV2` type uses the property `bucket` instead of name. Other resources, such as `aws.kms.Key`, do not have physical names and use other auto-generated IDs to uniquely identify them.

Overriding auto-naming makes your project susceptible to naming collisions. As a result, for resources that may need to be replaced, you should specify `deleteBeforeReplace: true` in the resource’s options. This option ensures that old resources are deleted before new ones are created, which will prevent those collisions.

Expand Down Expand Up @@ -283,29 +283,29 @@ resources:
Each resource is an instance of a specific Pulumi resource type. This type is specified by a type token in the format `<package>:<module>:<typename>`. Concrete examples of this format are:

- `aws:s3/bucket:Bucket`
- `aws:s3/bucketv2:BucketV2`
- `azure-native:compute:VirtualMachine`
- `kubernetes:apps/v1:Deployment`
- `random:index:RandomPassword`

The `<package>` component of the type (e.g. `aws`, `azure-native`, `kubernetes`, `random`) specifies which [Pulumi Package](/docs/using-pulumi/pulumi-packages/) defines the resource. This is mapped to the package in the [Pulumi Registry](/registry/) and to the underlying [Resource Provider](/docs/concepts/resources/providers/).

The `<module>` component of the type (e.g. `s3/bucket`, `compute`, `apps/v1`, `index`) is the module path where the resource lives within the package. It is `/` delimited by component of the path. Per-language Pulumi SDKs use the module path to emit nested namespaces/modules in a language-specific way to organize all the types defined in a package. For example, the `Deployment` resource above is available at `kubernetes.apps.v1.Deployment` in TypeScript and in the `github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/apps/v1` module in Go. For historical reasons only, some packages include the type name itself as a final component of the module (e.g. `s3/bucket` for the type name `Bucket`) - in this case, this component is not included in the SDK namespace. The name `index` indicates that the resource is not nested, and is instead available at the top level of the package. For example, the `RandomPassword` resource above is available at `random.RandomPassword` in TypeScript.
The `<module>` component of the type (e.g. `s3/bucket`, `compute`, `apps/v1`, `index`) is the module path where the resource lives within the package. It is `/` delimited by component of the path. Per-language Pulumi SDKs use the module path to emit nested namespaces/modules in a language-specific way to organize all the types defined in a package. For example, the `Deployment` resource above is available at `kubernetes.apps.v1.Deployment` in TypeScript and in the `github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/apps/v1` module in Go. For historical reasons only, some packages include the type name itself as a final component of the module (e.g. `s3/bucketv2` for the type name `BucketV2`) - in this case, this component is not included in the SDK namespace. The name `index` indicates that the resource is not nested, and is instead available at the top level of the package. For example, the `RandomPassword` resource above is available at `random.RandomPassword` in TypeScript.

The `<typename>` component of the type (e.g. `Bucket`, `VirtualMachine`, `Deployment`, `RandomPassword`) is the identifier used to refer to the resource itself. It is mapped to the class or constructor name in the per-language Pulumi SDK.
The `<typename>` component of the type (e.g. `BucketV2`, `VirtualMachine`, `Deployment`, `RandomPassword`) is the identifier used to refer to the resource itself. It is mapped to the class or constructor name in the per-language Pulumi SDK.

Note that because of some of the historical details of how `<module>` is defined, a "simplified" resource type name is accepted or presented in certain places, and mapped into the "full" resource type name specified above. The simplified resource type name applies the following rules:

1. If the type token is two components instead of three, that is `<package>:<typename>`, it is interpreted as if it was `<package>:index:<typename>`.
2. The repetition of the `<typename>` as part of the module definition is not required, and will be inferred if necessary - that is `aws:s3:Bucket` will be interpreted as referring to `aws:s3/bucket:Bucket`.
2. The repetition of the `<typename>` as part of the module definition is not required, and will be inferred if necessary - that is `aws:s3:BucketV2` will be interpreted as referring to `aws:s3/bucketv2:BucketV2`.

This "simplified" type name format is currently used in the following places:

- The [Pulumi YAML](/docs/languages-sdks/yaml/) language allows simple type names to be used as the `type` of a resource.

The examples above can be written in simplified form as:

- `aws:s3:Bucket`
- `aws:s3:BucketV2`
- `azure-native:compute:VirtualMachine`
- `kubernetes:apps/v1:Deployment`
- `random:RandomPassword`
Expand All @@ -319,7 +319,7 @@ The URN is automatically constructed from the project name, stack name, resource
The following is an example of a URN:

```text
urn:pulumi:production::acmecorp-website::custom:resources:Resource$aws:s3/bucket:Bucket::my-bucket
urn:pulumi:production::acmecorp-website::custom:resources:Resource$aws:s3/bucketv2:BucketV2::my-bucket
^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^
<stack-name> <project-name> <parent-type> <resource-type> <resource-name>
```
Expand All @@ -329,7 +329,7 @@ The type components of the URN are [resource types](#types) as defined above, an
The URN must be globally unique. This means all of the components that go into a URN must be unique within your program. If you create two resources with the same name, type, and parent path, for instance, you will see an error:

```bash
error: Duplicate resource URN 'urn:pulumi:production::acmecorp-website::custom:resources:Resource$aws:s3/bucket:Bucket::my-bucket'; try giving it a unique name
error: Duplicate resource URN 'urn:pulumi:production::acmecorp-website::custom:resources:Resource$aws:s3/bucketv2:BucketV2::my-bucket'; try giving it a unique name
```

Any change to the URN of a resource causes the old and new resources to be treated as unrelated—the new one will be created (since it was not in the prior state) and the old one will be deleted (since it is not in the new desired state). This behavior happens when you change the `name` used to construct the resource or the structure of a resource’s parent hierarchy.
Expand Down
2 changes: 1 addition & 1 deletion content/docs/iac/concepts/testing/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ integration.ProgramTest(t, &integration.ProgramTestOptions{
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
     var foundBuckets int
    for _, res := range stack.Deployment.Resources {
if res.Type == "aws:s3/bucket:Bucket" {
if res.Type == "aws:s3/bucketv2:BucketV2" {
     foundBuckets++
}
    }
Expand Down
6 changes: 3 additions & 3 deletions content/docs/iac/concepts/update-plans.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ template](https://github.com/pulumi/templates/tree/master/aws-typescript).
"aws:region": "us-east-1"
},
"resourcePlans": {
"urn:pulumi:dev::examplets::aws:s3/bucket:Bucket::my-bucket": {
"urn:pulumi:dev::examplets::aws:s3/bucketv2:BucketV2::my-bucket": {
"goal": {
"type": "aws:s3/bucket:Bucket",
"type": "aws:s3/bucketv2:BucketV2",
"name": "my-bucket",
"custom": true,
"inputDiff": {
Expand Down Expand Up @@ -180,7 +180,7 @@ template](https://github.com/pulumi/templates/tree/master/aws-typescript).
This is a textual representation of the goals, and operation steps that the program planned to take.

For the most part this should be readable without much internal knowledge of Pulumi, for example you can see
this plans on creating an `s3:Bucket` object called "my-bucket-6209a55". A lot of the other options correspond
this plans on creating an `s3:BucketV2` object called "my-bucket-6209a55". A lot of the other options correspond
directly to things you should be familiar with from Pulumi programs (such as parents, providers, custom or
component resources).

Expand Down
4 changes: 2 additions & 2 deletions content/docs/iac/get-started/aws/deploy-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Previewing update (dev):
Type Name Plan
+ pulumi:pulumi:Stack quickstart-dev create
+ └─ aws:s3:Bucket my-bucket create
+ └─ aws:s3:BucketV2 my-bucket create
Resources:
+ 2 to create
Expand All @@ -42,7 +42,7 @@ Updating (dev):
Type Name Status
+ pulumi:pulumi:Stack quickstart-dev created (4s)
+ └─ aws:s3:Bucket my-bucket created (2s)
+ └─ aws:s3:BucketV2 my-bucket created (2s)
Outputs:
bucketName: "my-bucket-58ce361"
Expand Down
14 changes: 7 additions & 7 deletions content/docs/iac/get-started/aws/modify-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ In `Program.cs`, create a new `BucketObject` right after creating the bucket its
// Create an S3 Bucket object
var bucketObject = new BucketObject("index.html", new BucketObjectArgs
{
Bucket = bucket.BucketName,
Bucket = bucket.Id,
Source = new FileAsset("./index.html")
});
```
Expand All @@ -140,7 +140,7 @@ package myproject;

import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.Bucket;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketObject;
import com.pulumi.aws.s3.BucketObjectArgs;
import com.pulumi.asset.FileAsset;
Expand All @@ -150,11 +150,11 @@ public class App {
Pulumi.run(ctx -> {

// Create an AWS resource (S3 Bucket)
var bucket = new Bucket("my-bucket");
var bucket = new BucketV2("my-bucket");

// Create an S3 Bucket object
new BucketObject("index.html", BucketObjectArgs.builder()
.bucket(bucket.id())
.bucket(bucket.bucket())
.source(new FileAsset("./index.html"))
.build()
);
Expand All @@ -180,19 +180,19 @@ description: A minimal AWS Pulumi YAML program
resources:
# Create an AWS resource (S3 Bucket)
my-bucket:
type: aws:s3:Bucket
type: aws:s3:BucketV2

# Create an S3 Bucket object
index.html:
type: aws:s3:BucketObject
properties:
bucket: ${my-bucket}
bucket: ${my-bucket.bucket}
source:
fn::fileAsset: ./index.html

outputs:
# Export the name of the bucket
bucketName: ${my-bucket.id}
bucketName: ${my-bucket.bucket}
```
{{% /choosable %}}
Expand Down
Loading

0 comments on commit b256390

Please sign in to comment.