https://pulumi.com logo
#getting-started
Title
# getting-started
s

stocky-restaurant-98004

07/19/2023, 4:11 PM
@gentle-application-59272 Can you provide an example that minimally reproduces the issue with a single Pulumi file and a Pulumi import JSON file with a single entry? It's not clear to me why you would need to export the provider (although I have not done bulk import with a named provider).
g

gentle-application-59272

07/19/2023, 4:21 PM
I should have created the reproducible from the start... sorry The export is just my vain attempt to try to get codegen working, i wanted to export something, anything
s

stocky-restaurant-98004

07/19/2023, 4:22 PM
What cloud are you importing resources from?
g

gentle-application-59272

07/19/2023, 4:23 PM
AWS
s

stocky-restaurant-98004

07/19/2023, 4:24 PM
I wrote a blog post on this subject (which you might already be aware of): https://www.pulumi.com/blog/automating-pulumi-import-to-bring-manually-created-resources-into-iac/ Curious how you are generating the bulk import JSON: Are you using boto3, or did you find a better way e.g. with Resource Manager's API?
g

gentle-application-59272

07/19/2023, 4:25 PM
I have only done any of it by hand so far
s

stocky-restaurant-98004

07/19/2023, 4:26 PM
Ok, so you're doing a proof of concept for import into Pulumi?
g

gentle-application-59272

07/19/2023, 4:26 PM
yep
s

stocky-restaurant-98004

07/19/2023, 4:26 PM
Do you have a ton of different resource types, or is it mostly core things like IAM, EC2, etc.?
g

gentle-application-59272

07/19/2023, 4:26 PM
my client's previous team(s) never put anything into IAC really
mostly vpc, s3, cloudfront, lambda
s

stocky-restaurant-98004

07/19/2023, 4:27 PM
Yup. I came from consulting, so I know how that goes!
g

gentle-application-59272

07/19/2023, 4:27 PM
we are having some true fun
s

stocky-restaurant-98004

07/19/2023, 4:28 PM
Lambda could be a little tricky b/c I don't know how it would handle the
code
param, but check out that blog post if you haven't already. There's a linked GH repo that should give you a starting point that you can expand upon. We'll gladly accept PRs as well as long as they can be tested without undue effort.
g

gentle-application-59272

07/19/2023, 4:30 PM
with terraform i typically ignored anything to do with the code component of lambdas, usually pushing up a blank/empty zip
then used other CICD controls to properly populate the lambda
recon it matters if resources names (in this case a route53 record) have dots' like
new aws.route53.Record('<http://mysite.com|mysite.com>')
or should i stick to
mysite-com
s

stocky-restaurant-98004

07/19/2023, 5:00 PM
You know you can export code from the Lambda service in the console, right?
g

gentle-application-59272

07/19/2023, 5:02 PM
Yeah sure i didn't mean that, what i meant to say is that typically when dealing with lambdas I let developers define their own for their api gateways using whatever tool they wanted, eg serverless or sam, or I defined more foundational lambdas such as sqs triggered lambdas via terraform but I set up separate CICD pipelines for those lambdas such that developers could develop them without having to run terraform
thus terraform never was involved with lambda code, which is how i'll be dealing with the lambdas on this project with pulumi. No idea how import will behave ofcourse
it might try to pull the code as a local zip, who knows
I think the lesson here is that IAC import is always hell
hey @stocky-restaurant-98004 one more queestion about this; does the codegen typically output the generated code to STDOUT or into index.ts?
s

stocky-restaurant-98004

07/20/2023, 2:41 PM
There's a file output option, but STDOUT is the default.
g

gentle-application-59272

07/20/2023, 3:51 PM
ok so that changes things, the issue with the variable name then must not have anything to do with what's in my files, it's just a label
i presumed it was inspecting index.ts trying to locate the variable statically, to then insert the resources under it
that's very useful to know