https://pulumi.com logo
Title
l

limited-carpenter-34991

05/27/2020, 1:43 PM
Hi there, if i import an existing resource in azure ( for example resource group) with the importId parameter inside the CustomResourceOptions, why does pulumi rename my resource ?
var resourceGroup = new ResourceGroup("resourceBla", new ResourceGroupArgs,
new CustomResourceOptions
{
 ImportId = "/subscriptions/4711/resourceGroups/resourceBla"
}); 

azure:core:ResourceGroup  resourceBla                  import     [diff: ~name]; 1 warning
a

ancient-megabyte-79588

05/27/2020, 2:08 PM
I don't think that using the ImportId causes it to actually import. This command gets the resource:
const resourceGroup = azure.core.ResourceGroup.get(resourceGroupName, resouceGroupId);
and this command with the
import
directive will import it and put it under stack management.
let server = new aws.ec2.Instance("web-server", {
    ami: "ami-6869aa05",
    instanceType: "t2.micro",
    securityGroups: [ group.name ],
}, { import: "i-06a1073de86f4adef" });
https://www.pulumi.com/docs/intro/concepts/programming-model/#import
At least, that is how I understand importing.
l

limited-carpenter-34991

05/27/2020, 2:39 PM
Ah sorry i missed this inside the documentation
Because of auto-naming, it is common to run into this when importing a resource’s name property. Unless you explicitly specify a name, Pulumi will auto-generate one, which is guaranteed not to match, because it will have a random hex suffix. To fix this problem, explicitly specify the resource’s name as described here. Notice that has been done in the above example for the EC2 security group, by passing 
"web-sg-62a569b"
 as its name property in its arguments.