quaint-teacher-33292
04/16/2019, 11:58 AMtall-librarian-49374
04/16/2019, 12:16 PMquaint-teacher-33292
04/16/2019, 12:22 PMstack export
on the configuration using get() and then stack import
on a configuration that defines the resource? Does that make sense?tall-librarian-49374
04/16/2019, 12:42 PMshy-army-45455
04/16/2019, 12:52 PMquaint-teacher-33292
04/16/2019, 12:58 PMtall-librarian-49374
04/16/2019, 1:01 PMpulumi refresh
should get you where you want to bequaint-teacher-33292
04/16/2019, 1:09 PMexport const database = new gcp.sql.DatabaseInstance('test-database-asd', {
databaseVersion: 'POSTGRES_11',
name: 'test-database-asd',
settings: {
diskAutoresize: false,
diskSize: 10,
diskType: 'PD_HDD',
tier: 'db-f1-micro'
}
});
AFAIK the name
parameter defines the name used in the API, the same one that can be seen on GCP. I already have a Cloud SQL instance with that name, in the same zone, but it is not being discovered by pulumi refresh
. Is there something else that needs to match up? I know there are some internal IDs being passed around, do I need to generate one of those?shy-army-45455
04/16/2019, 1:14 PMquaint-teacher-33292
04/16/2019, 1:15 PMgcp.sql.DatabaseInstance.get('test-database-asd', 'test-database-asd');
, then ran pulumi up
to fetch this data into the internal cache. Then replaced that code with a definition that matches the state of the resource in GCP. Then ran pulumi refresh
and it went fine, unchanged. Then to test, I increased diskSize and ran pulumi up
. It correctly diffed the state before & after, and is recommending a replace
operation.replace
sounds destructive, but since it has no real data I will see what it actually doesUpdating (staging):
Type Name Status Info
pulumi:pulumi:Stack estetio-staging **failed** 1 error
> └─ gcp:sql:DatabaseInstance test-database-asd **reading failed** [diff: -__defaults,databaseVersion,masterInstanceName,name,project,region,settings]; 1 error
Diagnostics:
pulumi:pulumi:Stack (estetio-staging):
error: update failed
gcp:sql:DatabaseInstance (test-database-asd):
error: Plan apply failed: Error, failed to create instance test-database-asd: googleapi: Error 409: The Cloud SQL instance already exists., instanceAlreadyExists
shy-army-45455
04/16/2019, 1:24 PMquaint-teacher-33292
04/16/2019, 1:32 PMpulumi preview --diff
Previewing update (staging):
pulumi:pulumi:Stack: (same)
[urn=urn:pulumi:staging::estetio::pulumi:pulumi:Stack::estetio-staging]
++gcp:sql/databaseInstance:DatabaseInstance: (create-replacement)
[id=test-database-asd]
[urn=urn:pulumi:staging::estetio::gcp:sql/databaseInstance:DatabaseInstance::test-database-asd]
databaseVersion: "POSTGRES_11"
name : "test-database-asd"
settings : {
diskAutoresize : true
diskSize : 10
diskType : "PD_HDD"
pricingPlan : "PER_USE"
replicationType: "SYNCHRONOUS"
tier : "db-f1-micro"
}
+-gcp:sql/databaseInstance:DatabaseInstance: (replace)
[id=test-database-asd]
[urn=urn:pulumi:staging::estetio::gcp:sql/databaseInstance:DatabaseInstance::test-database-asd]
databaseVersion: "POSTGRES_11"
name : "test-database-asd"
settings : {
diskAutoresize : true
diskSize : 10
diskType : "PD_HDD"
pricingPlan : "PER_USE"
replicationType: "SYNCHRONOUS"
tier : "db-f1-micro"
}
<<gcp:sql/databaseInstance:DatabaseInstance: (discard-replaced)
[id=test-database-asd]
[urn=urn:pulumi:staging::estetio::gcp:sql/databaseInstance:DatabaseInstance::test-database-asd]
databaseVersion: "POSTGRES_11"
name : "test-database-asd"
settings : {
diskAutoresize : true
diskSize : 10
diskType : "PD_HDD"
pricingPlan : "PER_USE"
replicationType: "SYNCHRONOUS"
tier : "db-f1-micro"
}
Resources:
+-1 to replace
1 unchanged
Permalink: file:///home/kuba/.pulumi/stacks/staging.json
shy-army-45455
04/16/2019, 1:36 PMquaint-teacher-33292
04/16/2019, 1:36 PM__meta
field in the stack JSON, and it happens to be hidden from the CLI diffs. Perhaps that's the onegentle-diamond-70147
04/16/2019, 2:50 PMrefresh
. Then write the code to get the refresh details to "match up".quaint-teacher-33292
04/16/2019, 2:58 PM"external": true
part of the JSON and it is reconciled properlyimport
operation take care of dropping this "external" field, or is it different entirely?gentle-diamond-70147
04/16/2019, 3:08 PMquaint-teacher-33292
04/16/2019, 3:10 PMpulumi stack import
, right?gentle-diamond-70147
04/16/2019, 3:14 PMstack import
command removes that.quaint-teacher-33292
04/16/2019, 3:31 PMget(...)
functions, run pulumi up
. Edit the stack json directly (or export -> modify -> import probably works too) to remove "external": true
, and that's it. No refresh
is needed, although the first time you update this resource, the schema will change slightly, some keys move around etc. But it's not destructive. Thank you for the help, I will note down this solution in the import/adopt issue on GH, so others are aware.tall-librarian-49374
04/16/2019, 3:33 PMget(...)
with a constructor at some point?quaint-teacher-33292
04/16/2019, 3:34 PM