Skip to content

Commit

Permalink
Add Move Resources Between Stacks Tutorial (#12637)
Browse files Browse the repository at this point in the history
* initializing content

* added example code placeholders

* updated content

* added example code

* added random package

* clean up code and content

* added remaining code examples in content

* added meta image

* updated estimated time

* removed unused img and updated link
  • Loading branch information
toriancrane authored Sep 27, 2024
1 parent ce61351 commit 6ae0bd7
Show file tree
Hide file tree
Showing 19 changed files with 684 additions and 0 deletions.
397 changes: 397 additions & 0 deletions content/tutorials/move-resources-between-stacks/index.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-csharp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Pulumi;
using Pulumi.Aws.S3;
using Pulumi.Random;
using System.Collections.Generic;

return await Deployment.RunAsync(() =>
{
var petName = new RandomPet("my-pet-name");

var bucket = new Bucket("b");

var index = new BucketObject("index.html", new BucketObjectArgs
{
Bucket = bucket.BucketName,
Content = "Thanks for using Pulumi!"
}, new CustomResourceOptions { Parent = bucket });

var randomSite = new BucketObject("random.html", new BucketObjectArgs
{
Bucket = bucket.BucketName,
Content = petName.Id
}, new CustomResourceOptions { Parent = bucket });

return new Dictionary<string, object?>
{
["PetName"] = petName.Id
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: aws-s3bucket-s3objects-random-csharp
runtime: dotnet
description: An example that deploys an S3 bucket, S3 bucket objects, and a Pulumi random resource.
config:
pulumi:tags:
value:
pulumi:template: aws-csharp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi" Version="3.*" />
<PackageReference Include="Pulumi.Aws" Version="6.*" />
<PackageReference Include="Pulumi.Random" Version="4.16.3" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-go/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: aws-s3bucket-s3objects-random-go
runtime: go
description: An example that deploys an S3 bucket, S3 bucket objects, and a Pulumi random resource.
config:
pulumi:tags:
value:
pulumi:template: aws-go
11 changes: 11 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module aws-s3bucket-s3objects-random-go

go 1.21

toolchain go1.21.0

require (
github.com/pulumi/pulumi-aws/sdk/v6 v6.37.1
github.com/pulumi/pulumi-random/sdk/v4 v4.16.3
github.com/pulumi/pulumi/sdk/v3 v3.121.0
)
41 changes: 41 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {

petName, err := random.NewRandomPet(ctx, "my-pet-name", nil)
if err != nil {
return err
}

bucket, err := s3.NewBucket(ctx, "b", nil)
if err != nil {
return err
}

_, err = s3.NewBucketObject(ctx, "index.html", &s3.BucketObjectArgs{
Bucket: bucket.ID(),
Content: pulumi.String("Thanks for using Pulumi!"),
}, pulumi.Parent(bucket))
if err != nil {
return err
}

_, err = s3.NewBucketObject(ctx, "random.html", &s3.BucketObjectArgs{
Bucket: bucket.ID(),
Content: petName.ID(),
}, pulumi.Parent(bucket))
if err != nil {
return err
}

ctx.Export("PetName", petName.ID())
return nil
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: aws-s3bucket-s3objects-random-javascript
runtime:
name: nodejs
options:
packagemanager: npm
typescript: false
description: An example that deploys an S3 bucket, S3 bucket objects, and a Pulumi random resource.
config:
pulumi:tags:
value:
pulumi:template: aws-javascript
27 changes: 27 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-javascript/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const pulumi = require("@pulumi/pulumi");
const random = require("@pulumi/random");
const aws = require("@pulumi/aws");

const petName = new random.RandomPet("my-pet-name");

const bucket = new aws.s3.Bucket("b");

const index = new aws.s3.BucketObject(
"index.html",
{
bucket: bucket.bucket,
content: "Thanks for using Pulumi!",
},
{ parent: bucket },
);

const randomSite = new aws.s3.BucketObject(
"random.html",
{
bucket: bucket.bucket,
content: petName.id,
},
{ parent: bucket },
);

exports.PetName = petName.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "aws-s3bucket-s3objects-random-javascript",
"main": "index.js",
"dependencies": {
"@pulumi/aws": "^6.0.0",
"@pulumi/awsx": "^2.0.2",
"@pulumi/pulumi": "^3.0.0",
"@pulumi/random": "^4.16.3"
}
}
11 changes: 11 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-python/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: aws-s3bucket-s3objects-random-python
runtime:
name: python
options:
toolchain: pip
virtualenv: venv
description: An example that deploys an S3 bucket, S3 bucket objects, and a Pulumi random resource.
config:
pulumi:tags:
value:
pulumi:template: aws-python
21 changes: 21 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-python/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pulumi
import pulumi_random as random
import pulumi_aws as aws

pet_name = random.RandomPet('my-pet-name')

bucket = aws.s3.Bucket("b")

index = aws.s3.BucketObject("index.html",
bucket=bucket.bucket,
content="Thanks for using Pulumi!",
opts=pulumi.ResourceOptions(parent=bucket)
)

random_site = aws.s3.BucketObject("random.html",
bucket=bucket.bucket,
content=pet_name.id,
opts=pulumi.ResourceOptions(parent=bucket)
)

pulumi.export('PetName', pet_name.id)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pulumi>=3.0.0,<4.0.0
pulumi-aws>=6.0.2,<7.0.0
pulumi-random
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: aws-s3bucket-s3objects-random-typescript
runtime:
name: nodejs
options:
packagemanager: npm
description: An example that deploys an S3 bucket, S3 bucket objects, and a Pulumi random resource.
config:
pulumi:tags:
value:
pulumi:template: aws-typescript
27 changes: 27 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-typescript/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
import * as aws from "@pulumi/aws";

const petName = new random.RandomPet("my-pet-name");

const bucket = new aws.s3.Bucket("b");

const index = new aws.s3.BucketObject(
"index.html",
{
bucket: bucket.bucket,
content: "Thanks for using Pulumi!",
},
{ parent: bucket },
);

const randomSite = new aws.s3.BucketObject(
"random.html",
{
bucket: bucket.bucket,
content: petName.id,
},
{ parent: bucket },
);

export const PetName = petName.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "aws-s3bucket-s3objects-random-typescript",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18",
"typescript": "^5.0.0"
},
"dependencies": {
"@pulumi/aws": "^6.0.0",
"@pulumi/awsx": "^2.0.2",
"@pulumi/pulumi": "^3.113.0",
"@pulumi/random": "^4.16.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.ts"
]
}
26 changes: 26 additions & 0 deletions static/programs/aws-s3bucket-s3objects-random-yaml/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: aws-s3bucket-s3objects-random-yaml
runtime: yaml
description: An example that deploys an S3 bucket, S3 bucket objects, and a Pulumi random resource.

resources:
pet-name:
type: random:RandomPet
my-bucket:
type: aws:s3:Bucket
index:
type: aws:s3:BucketObject
properties:
bucket: ${my-bucket.bucket}
content: "Thanks for using Pulumi!"
options:
parent: ${my-bucket}
random-site:
type: aws:s3:BucketObject
properties:
bucket: ${my-bucket.bucket}
content: ${pet-name.id}
options:
parent: ${my-bucket}

outputs:
PetName: ${pet-name.id}

0 comments on commit 6ae0bd7

Please sign in to comment.