Skip to content

Commit 3a71735

Browse files
committed
Updating component resource to be a more complete picture
1 parent 29a87bf commit 3a71735

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

content/docs/iac/concepts/resources/components.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,13 @@ let bucket = new aws.s3.BucketV2(`${name}-bucket`,
158158
{{% choosable language python %}}
159159

160160
```python
161-
bucket = s3.BucketV2(f"{name}-bucket",
162-
opts=pulumi.ResourceOptions(parent=self))
161+
class MyComponent(pulumi.ComponentResource):
162+
def __init__(self, name, my_component_args, opts = None):
163+
super().__init__('pkg:index:MyComponent', name, None, opts)
164+
165+
# Create Child Resource
166+
self.bucket = s3.BucketV2(f"{name}-bucket",
167+
opts=pulumi.ResourceOptions(parent=self))
163168
```
164169

165170
{{% /choosable %}}
@@ -224,8 +229,17 @@ this.registerOutputs({
224229
{{% choosable language python %}}
225230

226231
```python
227-
self.register_outputs({
228-
"bucketDnsName": bucket.bucketDomainName
232+
class MyComponent(pulumi.ComponentResource):
233+
def __init__(self, name, my_component_args, opts = None):
234+
super().__init__('pkg:index:MyComponent', name, None, opts)
235+
236+
# Create Child Resource
237+
self.bucket = s3.BucketV2(f"{name}-bucket",
238+
opts=pulumi.ResourceOptions(parent=self))
239+
240+
# Registering Component Outputs
241+
self.register_outputs({
242+
"bucketDnsName": bucket.bucketDomainName
229243
})
230244
```
231245

0 commit comments

Comments
 (0)