pulumiverse / pulumi-mssql

Pulumi provider for Microsoft SQL Server and Azure SQL
Apache License 2.0
2 stars 1 forks source link

I cannot get imports to work #13

Open gpduck opened 6 months ago

gpduck commented 6 months ago

I have tried both importing in code and using pulumi import to import existing AzureadUser, SqlLogin, and SqlUser resources, but I cannot get any of them to successfully import.

When importing via code (my project is Typescript), I get an error "inputs to import do not match the existing resource". I have used getAuzreadUser to verify that I am setting the correct values for databaseId, userObjectId, and name, and that I'm using the correct id for the import.

When importing via the cli, I'm running the command as follows:

pulumi import mssql:index/azureadUser:AzureadUser aduser '5/7' --provider sqlprovider=urn:pulumi:test::TestProject::pulumi:providers:mssql::sqlprovider::38171ea1-3e53-4f70-adc8-4b0a842873f7

I get the following warnings:

    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `mssql` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: mssql:index/azureadUser:AzureadUser resource 'aduser' has a problem: Missing required property 'userObjectId': Azure AD object_id of the user. This can be either regular user or a group.
    warning: mssql:index/azureadUser:AzureadUser resource 'aduser' has a problem: Missing required property 'databaseId': ID of database. Can be retrieved using `mssql_database` or `SELECT DB_ID('<db_name>')`.

If I view details or go ahead with the import, the resource only has id set, none of the other properties are being returned by the import. Importing and then trying to set the values in code results in the resource being replaced which defeats the purpose of importing them.

tmeckel commented 5 months ago

@gpduck

If I view details or go ahead with the import, the resource only has id set, none of the other properties are being returned by the import. Importing and then trying to set the values in code results in the resource being replaced which defeats the purpose of importing them.

That's (normally) the nature of an import. The ID of the resource gets added to the stack (state). On the next refresh the properties get populated (read) from the (target) system.

Will your infrastructure run successful after an import? Or do you get any additional errors, especially when you run pulumi preview --refresh