Skip to content
Open
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
140 changes: 42 additions & 98 deletions src/content/docs/pulumi/tutorial/hello-world.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,14 @@ const config = new pulumi.Config();
const accountId = config.require("accountId");
const domain = config.require("domain");

const content = `export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};`
const content = `addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});`

const worker = new cloudflare.WorkersScript("hello-world-worker", {
accountId: accountId,
name: "hello-world-worker",
content: content,
module: true, // ES6 module
});
```

Expand All @@ -305,18 +301,14 @@ const config = new pulumi.Config();
const accountId = config.require("accountId");
const domain = config.require("domain");

const content = `export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};`
const content = `addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});`

const worker = new cloudflare.WorkersScript("hello-world-worker", {
accountId: accountId,
name: "hello-world-worker",
content: content,
module: true, // ES6 module
});
```

Expand All @@ -333,19 +325,15 @@ CONFIG = pulumi.Config()
ACCOUNT_ID = CONFIG.get("accountId")
DOMAIN = CONFIG.require("domain")
CONTENT = """
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
"""

worker = cloudflare.WorkersScript("hello-world-worker",
account_id=ACCOUNT_ID,
name="hello-world-worker",
content=CONTENT,
module=True # ES6 module
)
```

Expand All @@ -368,18 +356,14 @@ func main() {
accountID := conf.Get("accountId")
domain := conf.Get("domain")
content := `
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
`
worker, err := cloudflare.NewWorkersScript(ctx, "hello-world-worker", &cloudflare.WorkersScriptArgs{
AccountId: pulumi.String(accountID),
Name: pulumi.String("hello-world-worker"),
Content: pulumi.String(content),
Module: pulumi.Bool(true), // ES6 module
})
if err != nil {
return err
Expand All @@ -406,12 +390,9 @@ public class App {
public static void main(String[] args) {
Pulumi.run(ctx -> {
var content = """
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
""";

var accountId = ctx.config().require("accountId");
Expand All @@ -420,7 +401,6 @@ public class App {
.accountId(accountId)
.name("hello-world-worker")
.content(content)
.module(true)
.build());

return;
Expand All @@ -443,20 +423,16 @@ return await Deployment.RunAsync(() =>
var accountId = config.Require("accountId");
var domain = config.Require("domain");
var content = @"
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response(""Hello World!"", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
";

var worker = new Cloudflare.WorkersScript("hello-world-worker", new()
{
AccountId = accountId,
Name = "hello-world-worker",
Content = content,
Module = true
});
return;
});
Expand All @@ -476,13 +452,9 @@ resources:
accountId: "${accountId}"
name: "hello-world-worker"
content: |
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
module: true
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
```

</TabItem> </Tabs>
Expand Down Expand Up @@ -788,18 +760,14 @@ const config = new pulumi.Config();
const accountId = config.require("accountId");
const domain = config.require("domain");

const content = `export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};`
const content = `addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});

const worker = new cloudflare.WorkersScript("hello-world-worker", {
accountId: accountId,
name: "hello-world-worker",
content: content,
module: true, // ES6 module
});

const zone = cloudflare.getZone({
Expand Down Expand Up @@ -840,18 +808,14 @@ const config = new pulumi.Config();
const accountId = config.require("accountId");
const domain = config.require("domain");

const content = `export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};`
const content = `addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});`

const worker = new cloudflare.WorkersScript("hello-world-worker", {
accountId: accountId,
name: "hello-world-worker",
content: content,
module: true, // ES6 module
});

const zone = cloudflare.getZone({
Expand Down Expand Up @@ -893,19 +857,15 @@ CONFIG = pulumi.Config()
ACCOUNT_ID = CONFIG.get("accountId")
DOMAIN = CONFIG.require("domain")
CONTENT = """
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
"""

worker = cloudflare.WorkersScript("hello-world-worker",
account_id=ACCOUNT_ID,
name="hello-world-worker",
content=CONTENT,
module=True # ES6 module
)

zone = cloudflare.get_zone(account_id=ACCOUNT_ID, name=DOMAIN)
Expand Down Expand Up @@ -949,18 +909,14 @@ func main() {
accountID := conf.Get("accountId")
domain := conf.Get("domain")
content := `
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
`
worker, err := cloudflare.NewWorkersScript(ctx, "hello-world-worker", &cloudflare.WorkersScriptArgs{
AccountId: pulumi.String(accountID),
Name: pulumi.String("hello-world-worker"),
Content: pulumi.String(content),
Module: pulumi.Bool(true), // ES6 module
})
if err != nil {
return err
Expand Down Expand Up @@ -1024,12 +980,9 @@ public class App {
public static void main(String[] args) {
Pulumi.run(ctx -> {
var content = """
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
""";

var accountId = ctx.config().require("accountId");
Expand All @@ -1039,7 +992,6 @@ public class App {
.accountId(accountId)
.name("hello-world-worker")
.content(content)
.module(true)
.build());
final var zone = CloudflareFunctions.getZone(GetZoneArgs.builder()
.accountId(accountId)
Expand Down Expand Up @@ -1082,20 +1034,16 @@ return await Deployment.RunAsync(() =>
var accountId = config.Require("accountId");
var domain = config.Require("domain");
var content = @"
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response(""Hello World!"", options);
},
};
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
";

var worker = new Cloudflare.WorkersScript("hello-world-worker", new()
{
AccountId = accountId,
Name = "hello-world-worker",
Content = content,
Module = true
});
var zone = Output.Create(Cloudflare.GetZone.InvokeAsync(new()
{
Expand Down Expand Up @@ -1149,13 +1097,9 @@ resources:
accountId: "${accountId}"
name: "hello-world-worker"
content: |
export default {
async fetch(request) {
const options = { headers: { 'content-type': 'text/plain' } };
return new Response("Hello World!", options);
},
};
module: true
addEventListener('fetch', event => {
event.respondWith(new Response("Hello World!"));
});
route:
type: cloudflare:WorkersRoute
properties:
Expand Down