Please, is there any way how to import a resource ...
# typescript
b
Please, is there any way how to import a resource and straight away modify it in one run? 🙂
s
I may be mistaken, but I don’t believe there is a way to do that.
l
No. Changes are detected between code and state. When you're importing, there is no state, only code and cloud. You need to import the existing cloud configuration in order to set up the current state, then change the code so that Pulumi can detect a change.
b
Understood, thank you!
b
Would love to be able to do this!
s
@blue-carpenter-4997 What’s the use case, if you don’t mind me asking?
b
It’s complicated. I am standing up new instances of ecs services that were previously built manually, but now via pulumi. To stand up an ecs service it needs a target group attached to a listener rule. The listener rules already exist. The migration plan is to modify the existing listener rules and slowly shift traffic from the old target group to the new one using percentages. I want to import the existing listener rule, send 100% traffic to the old target group, then 0% to the new one, then stand up the service. This will allow it to get running. Then, using a pulumi config parameter set by ci cd, I’ll shift that traffic the other direction when we’ve confirmed the service works. The problem is that I cannot import the listener rule and add a second target group definition in the same go. I’m going to see if I can use my firstrun logic to solve this though
Basically this would be running in ci cd and execute in two parts, the “First run” which creates everything except for the service, and the second run which executes after an image has been uploaded to the ecr registry.
s
Gotcha. Thanks for the additional information & context!
b
np, I’m just going to see if I can modify the content of the listener rule definition depending on if it’s first run or not. So the first run it’ll import without any changes, and second it’ll remove the import statement and add a new targetGroup block
b
For me the use case was to create a new GCP project, have it create the default network, import the default network and modify it to suit my needs (update secondary IP ranges).