delightful-queen-14969
11/11/2025, 10:27 PMdelightful-queen-14969
11/11/2025, 10:43 PMlittle-cartoon-10569
11/11/2025, 10:56 PMname only. I definitely don't like adding the resource type into the name (though it seems to be hugely popular.. no idea why). The only time I change the name of a child from that of the parent is when there's more than one child of that type.little-cartoon-10569
11/11/2025, 10:57 PMnew aws.s3.Bucket(`${name}-bucket`, {});
Ick. What's wrong with
new aws.s3.Bucket(name, {})
?little-cartoon-10569
11/11/2025, 11:00 PMAlso, when constructing a resource, children must be registered as such. To do this, pass the component resource itself as the parent option.That's not a "must". You can pass anything as the parent, or pass nothing. It won't break (so long as you don't have circular dependencies). It's just a good idea to pass the component resource as the parent, most of the time.
delightful-queen-14969
11/11/2025, 11:12 PMclass EC2SecurityGroup(pulumi.ComponentResource):
"""AWS EC2 Security Group."""
security_group_id: Output[str]
"""The ID of the security group."""
vpc_id: Output[str]
"""The VPC ID the security group is in."""
def __init__(
self,
resource_id: str,
args: EC2SecurityGroupArgs,
opts: pulumi.ResourceOptions | None = None,
) -> None:
"""AWS EC2 Security Group."""
super().__init__("my:custom:SecurityGroup", resource_id, None, opts=opts)
security_group = pulumi_aws.ec2.SecurityGroup(
"security-group",
group_name=args.name,
group_name_prefix=args.name_prefix,
description=args.description,
tags=args.tags,
vpc_id=args.vpc_id,
opts=opts.merge(pulumi.ResourceOptions(parent=self)),
)
If I use a static name for the security group to be something like "security-group" and not name , then if I create two instances of the component I get a name clash on the child security group resource. However, if I use some dynamic name like name, then when you pass aliases=[pulumi.Alias(name="old-name")] to the ResourceOptions object of the parent, that takes effect only on the parent and not on the security group child resource underneathdelightful-queen-14969
11/11/2025, 11:14 PMlittle-cartoon-10569
11/11/2025, 11:16 PMname to all the children. This will handle 90% of caseslittle-cartoon-10569
11/11/2025, 11:17 PMdelightful-queen-14969
11/12/2025, 12:05 AMlittle-cartoon-10569
11/12/2025, 12:17 AMlittle-cartoon-10569
11/12/2025, 12:17 AMdelightful-queen-14969
11/12/2025, 12:17 AMlittle-cartoon-10569
11/12/2025, 12:18 AMlittle-cartoon-10569
11/12/2025, 12:18 AMlittle-cartoon-10569
11/12/2025, 12:18 AMdelightful-queen-14969
11/12/2025, 12:19 AMlittle-cartoon-10569
11/12/2025, 12:19 AMlittle-cartoon-10569
11/12/2025, 12:20 AMlittle-cartoon-10569
11/12/2025, 12:20 AMdelightful-queen-14969
11/12/2025, 12:21 AMlittle-cartoon-10569
11/12/2025, 12:21 AMpulumi up, then remove the aliases from code.delightful-queen-14969
11/12/2025, 12:22 AMlittle-cartoon-10569
11/12/2025, 12:22 AMlittle-cartoon-10569
11/12/2025, 12:22 AMdelightful-queen-14969
11/12/2025, 12:23 AMlittle-cartoon-10569
11/12/2025, 12:27 AMdelightful-queen-14969
11/12/2025, 12:28 AMdelightful-queen-14969
11/12/2025, 12:28 AMdelightful-queen-14969
11/12/2025, 12:29 AMdelightful-queen-14969
11/12/2025, 12:30 AMlittle-cartoon-10569
11/12/2025, 12:31 AMstocky-restaurant-98004
11/17/2025, 3:13 PM${name}-cluster.
I'll ensure that we note the specific case of renames (which I had not even considered - thank you!)delightful-queen-14969
11/17/2025, 9:18 PMstocky-restaurant-98004
11/17/2025, 10:00 PMdelightful-queen-14969
11/17/2025, 10:02 PMdelightful-queen-14969
11/17/2025, 10:05 PM