sparse-intern-71089
06/19/2019, 11:55 PMearly-musician-41645
06/19/2019, 11:59 PMasync delete(id, props) method requires some auth arguments to form a REST DELETE request. For the async create(inputs) I just added the auth data into the inputs and had no trouble.
How can I make those available to delete?white-balloon-205
early-musician-41645
06/20/2019, 12:01 AMwhite-balloon-205
inputs probably isn't right here - there won't be any inputs during a delete.early-musician-41645
06/20/2019, 12:02 AMwhite-balloon-205
It's more complicated - the auth is pulled from aws secretsmanagerThat should still be possible. Is it pulled from secrets manager at deployment time via
aws.secretsmanager.getSecretVersion?early-musician-41645
06/20/2019, 12:04 AMaws-sdk instead. So the secret is pulled like this:
28 var secretsmanager = new AWS.SecretsManager();
29 secretsmanager.getSecretValue({ SecretId: "eshamay-test" }, function(err: any, data: any) {
30 if (err) {
31 console.log("ERROR getting secret for service account", err);
32 throw err;
33 } else {
34 const savedSearch = new splunk.SavedSearch("foo-search", {
35 name: "foo-eshamay-test-1",
36 description: "eshamay's test search",
37 search: 'search index=online_prod source="*10ay*" earliest=-5m | stats count as Total',
38 splunkAuthSecret: data.SecretString,
39 });
40 }
41 });
42early-musician-41645
06/20/2019, 12:04 AMpulumi.dynamic.Resourceearly-musician-41645
06/20/2019, 12:05 AMearly-musician-41645
06/20/2019, 12:15 AM81 export class SavedSearch extends pulumi.dynamic.Resource {
82 public readonly name: pulumi.Output<string>;
83
84 private static provider = new SavedSearchProvider();
85
86 constructor(name: string, props: SavedSearchInput, opts?: pulumi.CustomResourceOptions) {
87 super(SavedSearch.provider, name, props, opts);
88
89 SavedSearch.provider.setAuth(props.splunkAuthSecret);
90 }
91 }
The creds are still in the inputs, but then I added a setter to the provider to create an instance variable that I can use in the delete methodearly-musician-41645
06/20/2019, 12:15 AMwhite-balloon-205
white-balloon-205
delete implementation is passed the old props for the resource, so any credentials provided at creation time will be available on the props.
Was that not working for you?
Note that the Pulumi program does not run at all during a destroy - so there is no way to pass new values in during the deletes for a destroy - the only data you have available to you is either:
1. The old inputs from when the resource was created/updated.
2. The serialized implementation of the delete body, which itself may have serialized in some state captured during that last update.