Hello, team! would like to kindly ask for help. We are planning to rewrite all infrastructure IaC c...
s
Hello, team! would like to kindly ask for help. We are planning to rewrite all infrastructure IaC code to pulumi. We would like to create reusable components (imagine terraform modules), which could be reused in different projects. How are you creating reusable components in golang? Do you use ComponentResources? Or just golang libraries? or anything else? Thanks!
e
https://www.pulumi.com/blog/pulumi-components/ <- read the recent blog on components, it's got examples of how to write components in Go that can then be used in other languages.
s
Hi Fraser, starting right now 🙂 Thank you!
I would be also interesting about organizing the ComponentResources. repo per component? or all components in one git repo? what about the versioning. Are there any examples of project using ComponentResources?
s
repo per component? or all components in one git repo?
Either of those is supported, it really depends on how you prefer setting up your project.
Are there any examples of project using ComponentResources?
There's a simple example in https://github.com/mikhailshilkov/comp-as-comp/tree/main/go
s
Thank you Thomas!
@echoing-dinner-19531 - As you suggested I read the Announcing the Next-Generation of Pulumi Components: Enabling Infrastructure Abstractions and I'm stuck. I dont understand the Define an Entry Point , where I dont see the connection to the SecureBucket component created above. Is it mandatory to have such entry point in ComponentResource? I would be greateful for any suggestions.
e
Is it mandatory to have such entry point in ComponentResource?
Yes, you need a main function to startup the component provider and tell it what components to use
where I dont see the connection to the SecureBucket component created above.
Copy code
WithComponents(
                infer.ComponentF(MyComponent),
            ).
^ That part, where you need to list each component type you've made, the
MyComponent
should say
NewSecureBucket
s
Thank you Fraser!
I have just crossed the Pulumi crosswalk. If I understand it correctly the Pulumi crosswalk libraries are "pre-built" ready to use abstractions, which are under the hood also using the ComponentResources. Is there any reason/downside of using Pulumi crosswalk why you guys havent mention it?
e
If I understand it correctly the Pulumi crosswalk libraries are "pre-built" ready to use abstractions, which are under the hood also using the ComponentResources
Yup
Is there any reason/downside of using Pulumi crosswalk why you guys havent mention it?
It's just one example of component resources. Some users fine the abstractions in crosswalk useful, others find it too limiting. I think it just wasn't thought of in the blog to refer to every other component library we publish, the point was to show off the new way for users to make components.
s
Thank you