fast-easter-23401
11/30/2021, 6:59 PMgcp.pubsub.SubscriptionIAMBinding
resource. I got first this error:
gcp:pubsub:SubscriptionIAMBinding (communications-applications-worker-iam-binding):
error: Preview failed: importing projects/<my-project-id>/subscriptions/<my-subscription-name>/roles/pubsub.subscriber: Wrong number of parts to Binding id [projects/<my-project-id>/subscriptions/<my-subscription-name>/roles/pubsub.subscriber]; expected 'resource_name role [condition_title]'.
Then, at the suggestions of @green-school-95910 (many thanks), I used a two-part string including the resource name and the role attached to the binding separated by a whitespace. But then I got the following error:
gcp:pubsub:SubscriptionIAMBinding (communications-applications-worker-iam-binding):
error: Preview failed: importing projects/<my-project-id>/subscriptions/<my-subscription-name> roles/pubsub.subscriber: project: required field is not set
I'm a bit puzzled, as the resource name does indeed contain a reference to the project. Here's my code (I'm using TS):
const communicationsApplicationsWorker = new gcp.pubsub.SubscriptionIAMBinding(
'communications-applications-worker-iam-binding',
{
project: projectId,
members: [
`serviceAccount:${serviceAccountEmail}`,
],
role: 'roles/pubsub.subscriber',
subscription: subscriptionName,
},
{
import:
`projects/${projectId}/subscriptions/${subscriptionName} roles/pubsub.subscriber`,
protect: true,
}
);
Any ideas what I'm doing wrong?
Many thanks 🙂prehistoric-activity-61023
11/30/2021, 7:01 PMfast-easter-23401
11/30/2021, 7:09 PMprehistoric-activity-61023
11/30/2021, 7:11 PMgreen-school-95910
11/30/2021, 7:11 PMproject
field out of the return of the API. If it does not exist it falls back to the provider value. If the provider does not have a project ID it fails with the message you sent.
Problem is, the method it uses on the API does not include a project
field on the response. So importing only works for pubsub subscriptions on the project set on the provider. It could get it from the resource path you are trying to import, but it doesn't. You can open an issue on Terraform's google-beta provider for that.prehistoric-activity-61023
11/30/2021, 7:31 PMgreen-school-95910
11/30/2021, 7:31 PMprehistoric-activity-61023
11/30/2021, 7:32 PMimport
commandgreen-school-95910
11/30/2021, 7:33 PMprehistoric-activity-61023
11/30/2021, 7:33 PMGOOGLE_PROJECT=use-this-you-blind-import-command pulumi import ...
😉green-school-95910
11/30/2021, 7:36 PMprehistoric-activity-61023
11/30/2021, 7:36 PMfast-easter-23401
11/30/2021, 7:37 PMprehistoric-activity-61023
11/30/2021, 7:37 PMpulum import
with --provider
flag)fast-easter-23401
11/30/2021, 7:41 PM