Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ bench_example.%:
mkdir -p ./traces
cd misc/test && PULUMI_TRACING_DIR=${PWD}/traces go test -test.v -run "^$*$$" -tags all

.PHONY: pr_preview
# PR-mode: run previews only for examples changed vs BASE_REF (default: origin/main|origin/master)
pr_preview:
bash scripts/pr-preview-changed.sh

.PHONY: format setup_python clean

# Create a virtual environment and install black
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ $ git pull origin master

Don't see an example listed? [Try Pulumi AI](https://www.pulumi.com/ai/?utm_campaign=pulumi-examples-github-repo&utm_source=github.com&utm_medium=pulumi-examples) and use natural-language prompts to generate Pulumi infrastructure-as-code programs in _any_ language.

## PR Preview Validation

When making changes to examples, either individual or in bulk, it's useful to validate those changes before submitting a pull request. This repository includes a `make pr_preview` target that provides preview-only sanity checks for changed examples in pull requests. This helps ensure examples remain functional without requiring full deployments.

```bash
# Run preview checks on all changed examples
make pr_preview

# Check what examples would be tested without running previews
DRY_LIST=1 make pr_preview

# Use a custom base branch for comparison
BASE_REF=origin/mybranch make pr_preview
```

The script assumes you have credentials for various providers configured. Examples that fail preview due to missing live resources or complex configuration requirements are expected and don't necessarily indicate problems.

## All Pulumi examples

- [AWS](#aws)
Expand Down
37 changes: 25 additions & 12 deletions aws-cs-assume-role/assume-role/AssumeRoleStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,34 @@ public AssumeRoleStack()
var awsConfig = new Pulumi.Config("aws");
var config = new Pulumi.Config();
var roleToAssumeARN = config.Require("roleToAssumeARN");
var provider = new Aws.Provider("privileged", new Aws.ProviderArgs
var isPreview = Deployment.Instance.IsDryRun;
if (!isPreview && roleToAssumeARN.StartsWith("arn:aws:iam::123456789012:role/preview-"))
{
AssumeRoles = new Aws.Inputs.ProviderAssumeRoleArgs[]
{
new Aws.Inputs.ProviderAssumeRoleArgs
throw new Exception("Configure a real roleToAssumeARN before 'pulumi up'. Example: pulumi config set aws-cs-assume-role:roleToAssumeARN arn:aws:iam::<account>:role/<roleName>");
}
var baseArgs = new Aws.ProviderArgs
{
Region = awsConfig.Require("region"),
};
var provider = new Aws.Provider("privileged",
isPreview
? baseArgs
: new Aws.ProviderArgs
{
RoleArn = roleToAssumeARN,
SessionName = "PulumiSession",
ExternalId = "PulumiApplication"
Region = baseArgs.Region,
AssumeRoles = new Aws.Inputs.ProviderAssumeRoleArgs[]
{
new Aws.Inputs.ProviderAssumeRoleArgs
{
RoleArn = roleToAssumeARN,
SessionName = "PulumiSession",
ExternalId = "PulumiApplication"
}
},
}
},
Region = awsConfig.Require("region"),
});
var bucket = new Aws.S3.BucketV2("myBucket", null, new CustomResourceOptions { Provider = provider });
this.BucketName = bucket.Bucket;
);
var bucket = new Aws.S3.Bucket("myBucket", null, new CustomResourceOptions { Provider = provider });
this.BucketName = bucket.Id;
}

[Output]
Expand Down
4 changes: 2 additions & 2 deletions aws-cs-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A static website that uses [S3's website support](https://docs.aws.amazon.com/Am
Previewing update (dev):
Type Name Plan
+ pulumi:pulumi:Stack aws-cs-s3-folder-dev create
+ └─ aws:s3:BucketV2 my-bucket create
+ └─ aws:s3:Bucket my-bucket create
+ ├─ aws:s3:BucketObject index.html create
+ └─ aws:s3:BucketObject favicon.png create

Expand All @@ -36,7 +36,7 @@ A static website that uses [S3's website support](https://docs.aws.amazon.com/Am
Updating (dev):
Type Name Status
+ pulumi:pulumi:Stack aws-cs-s3-folder-dev created
+ └─ aws:s3:BucketV2 my-bucket created
+ └─ aws:s3:Bucket my-bucket created
+ ├─ aws:s3:BucketObject index.html created
+ └─ aws:s3:BucketObject favicon.png created

Expand Down
8 changes: 4 additions & 4 deletions aws-cs-s3-folder/WebsiteStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class WebsiteStack : Stack
public WebsiteStack()
{
// Create an AWS resource (S3 Bucket)
var bucket = new BucketV2("my-bucket", new BucketV2Args {});
var bucket = new Bucket("my-bucket", new BucketArgs {});

var bucketWebsite = new BucketWebsiteConfigurationV2("website-config", new()
var bucketWebsite = new BucketWebsiteConfiguration("website-config", new()
{
Bucket = bucket.Id,
IndexDocument = new BucketWebsiteConfigurationV2IndexDocumentArgs
IndexDocument = new BucketWebsiteConfigurationIndexDocumentArgs
{
Suffix = "index.html",
},
Expand Down Expand Up @@ -46,7 +46,7 @@ public WebsiteStack()
var bucketObject = new BucketObject(name, new BucketObjectArgs
{
Acl = "public-read",
Bucket = bucket.Bucket,
Bucket = bucket.Id,
ContentType = contentType,
Source = new FileAsset(file)
}, new CustomResourceOptions {Parent = bucket, DependsOn = new Pulumi.Resource[]{ publicAccessBlock, ownershipControls }});
Expand Down
12 changes: 6 additions & 6 deletions aws-fs-s3-folder/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ open Pulumi.Aws.S3
let infra () =

// Create an AWS resource (S3 Bucket)
let bucket = BucketV2("my-bucket", BucketV2Args())
let bucket = Bucket("my-bucket", BucketArgs())

let website =
BucketWebsiteConfigurationV2("website",
BucketWebsiteConfigurationV2Args
(Bucket = bucket.Bucket,
IndexDocument = new BucketWebsiteConfigurationV2IndexDocumentArgs(Suffix = "index.html")),
BucketWebsiteConfiguration("website",
BucketWebsiteConfigurationArgs
(Bucket = bucket.Id,
IndexDocument = new BucketWebsiteConfigurationIndexDocumentArgs(Suffix = "index.html")),
CustomResourceOptions (Parent = bucket))

let ownershipControls =
Expand Down Expand Up @@ -44,7 +44,7 @@ let infra () =
BucketObject(name,
BucketObjectArgs
(Acl = input "public-read",
Bucket = io bucket.Bucket,
Bucket = io bucket.Id,
ContentType = input contentType,
Source = input (FileAsset file :> AssetOrArchive)),
CustomResourceOptions (Parent = bucket, DependsOn = inputList [input ownershipControls; input publicAccessBlock])))
Expand Down
4 changes: 2 additions & 2 deletions aws-fs-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A static website that uses [S3's website support](https://docs.aws.amazon.com/Am
Previewing update (dev):
Type Name Plan
+ pulumi:pulumi:Stack aws-cs-s3-folder-dev create
+ └─ aws:s3:BucketV2 my-bucket create
+ └─ aws:s3:Bucket my-bucket create
+ ├─ aws:s3:BucketObject index.html create
+ └─ aws:s3:BucketObject favicon.png create

Expand All @@ -36,7 +36,7 @@ A static website that uses [S3's website support](https://docs.aws.amazon.com/Am
Updating (dev):
Type Name Status
+ pulumi:pulumi:Stack aws-cs-s3-folder-dev created
+ └─ aws:s3:BucketV2 my-bucket created
+ └─ aws:s3:Bucket my-bucket created
+ ├─ aws:s3:BucketObject index.html created
+ └─ aws:s3:BucketObject favicon.png created

Expand Down
2 changes: 1 addition & 1 deletion aws-fs-s3-folder/aws-cs-s3-folder.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Pulumi" Version="3.*" />
<PackageReference Include="Pulumi.FSharp" Version="3.*" />
<PackageReference Include="Pulumi.Aws" Version="6.*" />
<PackageReference Include="Pulumi.Aws" Version="7.*" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions aws-go-console-slack-notification/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ func upRegion(ctx *pulumi.Context, regionName string) error {
return err
}

bucket, err := s3.NewBucketV2(ctx, resourceName, &s3.BucketV2Args{
bucket, err := s3.NewBucket(ctx, resourceName, &s3.BucketArgs{
ForceDestroy: pulumi.Bool(true),
}, pulumi.Provider(awsProvider))
if err != nil {
return err
}

if trailObjectExpirationInDays != 0 {
_, err := s3.NewBucketLifecycleConfigurationV2(ctx, resourceName, &s3.BucketLifecycleConfigurationV2Args{
_, err := s3.NewBucketLifecycleConfiguration(ctx, resourceName, &s3.BucketLifecycleConfigurationArgs{
Bucket: bucket.Bucket,
Rules: s3.BucketLifecycleConfigurationV2RuleArray{
s3.BucketLifecycleConfigurationV2RuleArgs{
Rules: s3.BucketLifecycleConfigurationRuleArray{
s3.BucketLifecycleConfigurationRuleArgs{
Status: pulumi.String("Enabled"),
Expiration: s3.BucketLifecycleConfigurationV2RuleExpirationArgs{
Expiration: s3.BucketLifecycleConfigurationRuleExpirationArgs{
Days: pulumi.Int(trailObjectExpirationInDays),
},
},
Expand Down
2 changes: 1 addition & 1 deletion aws-go-s3-folder-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ with `***`.
Type Name Status
+ pulumi:pulumi:Stack aws-go-s3-folder-component-website-component-testing created
+ └─ pulumi:example:S3Folder pulumi-static-site created
+ ├─ aws:s3:BucketV2 pulumi-static-site created
+ ├─ aws:s3:Bucket pulumi-static-site created
+ ├─ aws:s3:BucketPolicy bucketPolicy created
+ ├─ aws:s3:BucketObject index.html created
+ └─ aws:s3:BucketObject favicon.png created
Expand Down
6 changes: 3 additions & 3 deletions aws-go-s3-folder-component/s3folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ func NewS3Folder(ctx *pulumi.Context, bucketName string, siteDir string, args *F
return nil, err
}
// Create a bucket and expose a website index document
siteBucket, err := s3.NewBucketV2(ctx, bucketName, &s3.BucketV2Args{}, pulumi.Parent(&resource))
siteBucket, err := s3.NewBucket(ctx, bucketName, &s3.BucketArgs{}, pulumi.Parent(&resource))
if err != nil {
return nil, err
}

siteWebsite, err := s3.NewBucketWebsiteConfigurationV2(ctx, "s3-website", &s3.BucketWebsiteConfigurationV2Args{
siteWebsite, err := s3.NewBucketWebsiteConfiguration(ctx, "s3-website", &s3.BucketWebsiteConfigurationArgs{
Bucket: siteBucket.Bucket,
IndexDocument: s3.BucketWebsiteConfigurationV2IndexDocumentArgs{
IndexDocument: s3.BucketWebsiteConfigurationIndexDocumentArgs{
Suffix: pulumi.String("index.html"),
},
})
Expand Down
2 changes: 1 addition & 1 deletion aws-go-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on

#: Resource Type Name Status Extra Inf
1: pulumi:pulumi:Stack website-testing + created
2: aws:s3:BucketV2 s3-website-bucket + created
2: aws:s3:Bucket s3-website-bucket + created
3: aws:s3:BucketPolicy bucketPolicy + created
4: aws:s3:BucketObject favicon.png + created
5: aws:s3:BucketObject index.html + created
Expand Down
6 changes: 3 additions & 3 deletions aws-go-s3-folder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create a bucket and expose a website index document
siteBucket, err := s3.NewBucketV2(ctx, "s3-website-bucket", &s3.BucketV2Args{})
siteBucket, err := s3.NewBucket(ctx, "s3-website-bucket", &s3.BucketArgs{})
if err != nil {
return err
}

siteWebsite, err := s3.NewBucketWebsiteConfigurationV2(ctx, "s3-website", &s3.BucketWebsiteConfigurationV2Args{
siteWebsite, err := s3.NewBucketWebsiteConfiguration(ctx, "s3-website", &s3.BucketWebsiteConfigurationArgs{
Bucket: siteBucket.Bucket,
IndexDocument: s3.BucketWebsiteConfigurationV2IndexDocumentArgs{
IndexDocument: s3.BucketWebsiteConfigurationIndexDocumentArgs{
Suffix: pulumi.String("index.html"),
},
})
Expand Down
2 changes: 1 addition & 1 deletion aws-js-s3-folder-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ with `***`.
Type Name Status Info
+ pulumi:pulumi:Stack aws-js-s3-folder-component-website-component-testing created
+ └─ examples:S3Folder pulumi-static-site created
+ ├─ aws:s3:BucketV2 pulumi-static-site created
+ ├─ aws:s3:Bucket pulumi-static-site created
+ ├─ aws:s3:BucketPolicy bucketPolicy created
+ ├─ aws:s3:BucketObject favicon.png created
+ └─ aws:s3:BucketObject index.html created
Expand Down
4 changes: 2 additions & 2 deletions aws-js-s3-folder-component/s3folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class S3Folder extends pulumi.ComponentResource {
super("pulumi:examples:S3Folder", bucketName, {}, opts); // Register this component with name pulumi:examples:S3Folder

// Create a bucket and expose a website index document
let siteBucket = new aws.s3.BucketV2(bucketName, {}, { parent: this }); // specify resource parent
let siteBucket = new aws.s3.Bucket(bucketName, {}, { parent: this }); // specify resource parent

let websiteConfig = new aws.s3.BucketWebsiteConfigurationV2("s3-website-bucket-config", {
let websiteConfig = new aws.s3.BucketWebsiteConfiguration("s3-website-bucket-config", {
bucket: siteBucket.id,
indexDocument: {
suffix: "index.html",
Expand Down
2 changes: 1 addition & 1 deletion aws-js-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ with `***`.

Type Name Status Info
+ pulumi:pulumi:Stack aws-js-s3-folder-website-testing. created
+ ├─ aws:s3:BucketV2 s3-website-bucket created
+ ├─ aws:s3:Bucket s3-website-bucket created
+ ├─ aws:s3:BucketPolicy bucketPolicy created
+ ├─ aws:s3:BucketObject favicon.png created
+ └─ aws:s3:BucketObject index.html created
Expand Down
4 changes: 2 additions & 2 deletions aws-js-s3-folder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const pulumi = require("@pulumi/pulumi");
const mime = require("mime");

// Create a bucket and expose a website index document
let siteBucket = new aws.s3.BucketV2("s3-website-bucket", {});
let siteBucket = new aws.s3.Bucket("s3-website-bucket", {});

let siteBucketWebsiteConfig = new aws.s3.BucketWebsiteConfigurationV2("s3-website-bucket-config", {
let siteBucketWebsiteConfig = new aws.s3.BucketWebsiteConfiguration("s3-website-bucket-config", {
bucket: siteBucket.id,
indexDocument: {
suffix: "index.html",
Expand Down
44 changes: 28 additions & 16 deletions aws-py-assume-role/assume-role/__main__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
# Copyright 2016-2020, Pulumi Corporation. All rights reserved.

import pulumi_aws as aws
from pulumi import Config, ResourceOptions, export
from pulumi import Config, ResourceOptions, export, runtime

config = Config()
role_to_assume_arn = config.require("roleToAssumeARN")
aws_config = Config("aws")

provider = aws.Provider(
"privileged",
assume_roles=[
{
"role_arn": role_to_assume_arn,
# session name can contain only the following special characters =,.@-
# if any other special character is used, an error stating that the role
# cannot be assumed will be returned
"session_name": "PulumiSession",
"externalId": "PulumiApplication",
}
],
region=aws_config.require("region"),
)
is_preview = runtime.is_dry_run()
# Apply-time guard: prevent using preview placeholder on apply
if not is_preview and role_to_assume_arn.startswith("arn:aws:iam::123456789012:role/preview-"):
raise Exception(
"Configure a real roleToAssumeARN before 'pulumi up'. Example: pulumi config set aws-py-assume-role:roleToAssumeARN arn:aws:iam::<account>:role/<roleName>"
)
if is_preview:
provider = aws.Provider(
"privileged",
region=aws_config.require("region"),
)
else:
provider = aws.Provider(
"privileged",
region=aws_config.require("region"),
assume_roles=[
{
"role_arn": role_to_assume_arn,
# session name can contain only the following special characters =,.@-
# if any other special character is used, an error stating that the role
# cannot be assumed will be returned
"session_name": "PulumiSession",
"externalId": "PulumiApplication",
}
],
)

# Creates an AWS resource (S3 Bucket)
bucket = aws.s3.BucketV2("my-bucket", opts=ResourceOptions(provider=provider))
bucket = aws.s3.Bucket("my-bucket", opts=ResourceOptions(provider=provider))

# Exports the DNS name of the bucket
export("bucket_name", bucket.bucket_domain_name)
4 changes: 2 additions & 2 deletions aws-py-redshift-glue-etl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
)

# Create an S3 bucket to store some raw data.
events_bucket = s3.BucketV2(
events_bucket = s3.Bucket(
"events",
force_destroy=True,
)
Expand Down Expand Up @@ -179,7 +179,7 @@
)

# Create an S3 bucket for Glue scripts and temporary storage.
glue_job_bucket = s3.BucketV2(
glue_job_bucket = s3.Bucket(
"glue-job-bucket",
force_destroy=True,
)
Expand Down
2 changes: 1 addition & 1 deletion aws-py-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ with `***`.

Type Name Plan
+ pulumi:pulumi:Stack aws-py-s3-folder-dev create
+ ├─ aws:s3:BucketV2 s3-website-bucket create
+ ├─ aws:s3:Bucket s3-website-bucket create
+ ├─ aws:s3:BucketObject index.html create
+ ├─ aws:s3:BucketObject python.png create
+ ├─ aws:s3:BucketObject favicon.png create
Expand Down
4 changes: 2 additions & 2 deletions aws-py-s3-folder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from pulumi import FileAsset, Output, export, ResourceOptions
from pulumi_aws import s3

web_bucket = s3.BucketV2("s3-website-bucket")
web_bucket = s3.Bucket("s3-website-bucket")

web_site = s3.BucketWebsiteConfigurationV2(
web_site = s3.BucketWebsiteConfiguration(
"s3-website", bucket=web_bucket.bucket, index_document={"suffix": "index.html"}
)

Expand Down
Loading
Loading