/
Program.cs
72 lines (60 loc) · 1.96 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
using System.Threading.Tasks;
using Pulumi;
class Resource : ComponentResource
{
public Resource(string name, ComponentResourceOptions options = null)
: base("my:module:Resource", name, options)
{
}
}
// Scenario #2 - adopt a resource into a component
class Component : ComponentResource
{
public Component(string name, ComponentResourceOptions options = null)
: base("my:module:Component", name, options)
{
}
}
// Scenario 3: adopt this resource into a new parent.
class Component2 : ComponentResource
{
public Component2(string name, ComponentResourceOptions options = null)
: base("my:module:Component2", name, options)
{
}
}
// Scenario 4: Make a child resource that is parented by opts instead of 'this'. Fix
// in the next step to be parented by this. Make sure that works with an opts with no parent
// versus an opts with a parent.
class Component3 : ComponentResource
{
public Component3(string name, ComponentResourceOptions options = null)
: base("my:module:Component3", name, options)
{
new Component2(name + "-child", options);
}
}
// Scenario 5: Allow multiple aliases to the same resource.
class Component4 : ComponentResource
{
public Component4(string name, ComponentResourceOptions options = null)
: base("my:module:Component4", name, options)
{
}
}
class Program
{
static Task<int> Main(string[] args)
{
return Deployment.RunAsync(() =>
{
var res2 = new Resource("res2");
var comp2 = new Component("comp2");
new Component2("unparented");
new Component3("parentedbystack");
new Component3("parentedbycomponent", new ComponentResourceOptions { Parent = comp2 });
new Component4("duplicateAliases", new ComponentResourceOptions { Parent = comp2 });
});
}
}