Hello! My team would love to create reusable `Comp...
# python
n
Hello! My team would love to create reusable
ComponentResources
that encode our best practices while allowing the calling code to override some aspects of the underlying AWS resources. We want to expose the available overrides as Pulumi’s
Args
objects. E.g.,:
Copy code
class SecureS3Bucket(pulumi.ComponentResource):
    def __init__(
        self,
        name: str,
        bucket_overrides: aws.s3.BucketArgs = aws.s3.BucketArgs(),
Is there a convenient way to manipulate/merge
BucketArgs
objects? E.g., we might overlay required attribute values on top of the supplied
bucket_overrides
argument before passing the merged object into the
Bucket(BucketArgs)
constructor. One way we’ve found is using a combination of
pulumi._types.input_type_to_dict(bucket_overrides)
to turn
BucketArgs
into a
dict
and
pulumi.set( args_object, "attribute", "value" )
to apply
dict
entries to a
BucketArgs
object.
g
This is one of the reasons I recommend TypeScript and interfaces. 😞
k
Hey @nice-father-44210 How did you structure your schema.json for this component resource? I’m trying to do something similar and am looking to unwrap the S3 BucketArgs and use them as inputs to my component resource
I was wondering if you imported these values somehow from the existing pulumi-aws schema.json or if you had to define each input individually?
n
@kind-jelly-61624 for now, we’re using a mono Git repo that contains both, the reusable components and the calling code. Haven’t yet had to interact with
schema.json
. But.. please do let me know if you solve it! I don’t know how much longer we’ll be able to get away with the mono repo approach 🙂
k
ah gotcha! will do!