Hi there, if i import an existing resource in azur...
# azure
l
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 ?
Copy code
var resourceGroup = new ResourceGroup("resourceBla", new ResourceGroupArgs,
new CustomResourceOptions
{
 ImportId = "/subscriptions/4711/resourceGroups/resourceBla"
}); 

azure:core:ResourceGroup  resourceBla                  import     [diff: ~name]; 1 warning
a
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.
Copy code
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
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.