able-tomato-34262
07/03/2018, 12:55 PMable-tomato-34262
07/03/2018, 1:23 PMpreview
and update
command using python take ~40 seconds for a 30 lines program ?able-tomato-34262
07/03/2018, 2:13 PMpulumi config set aws:region eu-west-1
( my resources were previously in us-east-1 ) and I expected pulumi to destroy all my resources in us-east-1
to create them in eu-west-1
but pulumi seemed to lost track of my resources then, I couldn't do anything, even destroy. Is that the expected behaviour ?able-tomato-34262
07/03/2018, 2:14 PMaws:region
back to us-east-1
, destroy, change the config again and then creates them in my new regionimportant-jackal-88836
07/03/2018, 10:43 PMimportant-jackal-88836
07/03/2018, 11:01 PMpulumi stack export
important-jackal-88836
07/03/2018, 11:04 PMwhite-balloon-205
07/03/2018, 11:05 PMable-tomato-34262
07/04/2018, 1:39 PMupdate
: I tried to update a stack which had no changes and it tried to delete some resource :
$ pulumi update
Previewing update of stack 'prod'
Previewing changes:
Type Name Plan Info
info: no changes required:
9 resources unchanged
Do you want to perform this update? yes
Updating stack 'prod'
Performing changes:
Type Name Status Info
* pulumi:pulumi:Stack first-pulumi-prod done
-- └─ aws:rds:Instance base_c **deleting failed** 2 errors
Diagnostics:
aws:rds:Instance: base_c
error: Plan apply failed: deleting urn:pulumi:prod::first-pulumi::aws:rds/instance:Instance::base_c: DB Instance FinalSnapshotIdentifier is required when a final snapshot is required
error: update failed
info: no changes required:
9 resources unchanged
Permalink: <https://app.pulumi.com/jnancel/prod/updates/13>
error: update failed
That's a pretty scary behavior. Any idea what might have happened ?able-tomato-34262
07/04/2018, 2:37 PMable-tomato-34262
07/04/2018, 2:54 PMable-tomato-34262
07/04/2018, 2:57 PMquaint-queen-37896
07/06/2018, 5:05 AMquaint-queen-37896
07/06/2018, 5:09 AMquaint-queen-37896
07/06/2018, 5:09 AMimage.png▾
quaint-queen-37896
07/06/2018, 6:32 AMquaint-queen-37896
07/06/2018, 6:33 AMcreamy-potato-29402
07/06/2018, 6:52 AMquaint-queen-37896
07/06/2018, 6:57 AMquaint-queen-37896
07/06/2018, 6:57 AMquaint-queen-37896
07/06/2018, 7:03 AMimage.png▾
quaint-queen-37896
07/06/2018, 7:03 AMwtfgarble
option here.. 404's 😕quaint-queen-37896
07/06/2018, 7:05 AMquaint-queen-37896
07/06/2018, 7:05 AMDo you want to perform this destroy? yes
Destroying stack 'wtfgarble'
Permalink: <https://app.pulumi.com/ctolkien/wtfgarble/updates/8>
error: failed to load resource plugin azure: failed to perform plugin load callback: failed to save snapshot: after mutation of snapshot: child resource urn:pulumi:wtfgarble::Soda-Digital/pulumi-test::azure:core/resourceGroup:ResourceGroup::test-pulumi refers to missing parent urn:pulumi:wtfgarble::Soda-Digital/pulumi-test::pulumi:pulumi:Stack::Soda-Digital/pulumi-test-wtfgarble
quaint-queen-37896
07/06/2018, 7:17 AMquaint-queen-37896
07/06/2018, 7:18 AMcreamy-potato-29402
07/06/2018, 7:18 AMtall-librarian-49374
07/06/2018, 2:34 PMcloud.API
, should I require
my modules inside the get
function itself? I tried to use request
imported on top of the files and it failed with a warning not to close on requires... So I do
endpoint.get("/", (req, res) => {
const request = require('request');
request(url, ...
helpful-lighter-74534
07/07/2018, 5:56 AMstocky-spoon-28903
07/08/2018, 1:24 PMnames.length
result of aws.getAvailabilityZones()
to pass into something that wants a number
, and then use the output of that to map to aws.ec2.Subnet
objects?stocky-spoon-28903
07/08/2018, 1:24 PMnames.length
result of aws.getAvailabilityZones()
to pass into something that wants a number
, and then use the output of that to map to aws.ec2.Subnet
objects?big-piano-35669
07/08/2018, 2:54 PMgetAvailabilityZones
function returns a Promise<number>
, so you'll need to either await
its value or use a callback to access it. I prefer await
, especially if you're using TypeScript, but it does come with one unfortunate "catch": in JS, you cannot await
at the top level (yet, there is a proposal to enable this).
So, this example code will fetch the AZs and simply print them out. From there you can create a subnet-per-AZ, etc.
import * as aws from "@pulumi/aws";
(async () => {
const zones = (await aws.getAvailabilityZones()).names;
console.log(`${zones.length} AZs found:`);
for (const zone of zones) {
console.log(`\t${zone}`);
}
})();
If you're creating these in a function, you won't need the cumbersome (async () => { ... })()
stuff. Instead, it'd just be something like async function createSubnets() { ... }
.
We do have an example of this in the AWS repo, but it's fairly buried and largely only there to serve as a test case: https://github.com/pulumi/pulumi-aws/tree/master/examples/webserver/variants/zones.stocky-spoon-28903
07/08/2018, 4:30 PMbig-piano-35669
07/08/2018, 4:37 PMasync function main() {
// all the things happen here
}
main();
We don't await the promise returned from main here, but that's okay, since Node.js keeps the program alive until the event loop quiesces.
Another approach is to try to scope the places where you need to do this. For instance, in the subnets case, you might have something like
async function createSubnets() {
const zones = (await aws.getAvailabilityZones()).names;
const subnets = [];
... create them ...
return subnets;
}
This can just "push the problem around", because of course the returned subnets array will be wrapped in a promise, but for some cases this is more appropriate. Because our Input<T>
type accepts promises, doing it like this can sometimes let you achieve a more dataflow style rather than needing to await all over the place.stocky-spoon-28903
07/08/2018, 4:39 PMasync function main()
, exporting anything becomes difficult as far as I can tellbig-piano-35669
07/08/2018, 4:52 PMasync function createResources() {
// do everything here, including awaiting
return {
a: ...,
b: ...,
};
}
let outputs = createResources();
export let a = outputs.then(out => out.a);
export let b = outputs.then(out => out.b);
I'm personally not happy with all this ceremony, but as you note, most of this comes from standard JS/TS promises stuff. @lemon-spoon-91807 and @white-balloon-205 had been exploring how to do data sources without needing promises, but I've lost track of where we landed (Node.js makes it hard, by design, to block the message loop).Is there a way to create a stack output by allocating something rather than by exporting it from the TS module?Not at the moment, but in principle there's no reason we couldn't. This is all implemented in https://github.com/pulumi/pulumi/blob/015344ab0693ca433d211698eddc6a6a85588bf0/sdk/nodejs/runtime/stack.ts#L27, as called by https://github.com/pulumi/pulumi/blob/015344ab0693ca433d211698eddc6a6a85588bf0/sdk/nodejs/cmd/run/index.ts#L248, by the way, if you were interested in poking around.
stocky-spoon-28903
07/08/2018, 5:01 PMbig-piano-35669
07/08/2018, 5:02 PMstocky-spoon-28903
07/08/2018, 5:04 PMbig-piano-35669
07/08/2018, 7:21 PMstocky-spoon-28903
07/08/2018, 9:04 PMbig-piano-35669
07/09/2018, 1:15 AMlemon-spoon-91807
07/09/2018, 1:18 AMbig-piano-35669
07/09/2018, 1:30 AMwhite-balloon-205
07/09/2018, 3:17 AMawait
in JavaScript. https://github.com/tc39/ecmascript-asyncawait/issues/9#issuecomment-39000615stocky-spoon-28903
07/09/2018, 7:28 AMasync function(): Promise<any>
from the (user-facing) entry-point module of a Pulumi stack, and if that is what you get back call it from the runtime and use the returned object as the outputs? That way the majority of the ceremony in the pattern above could be removed and replaced with:
interface StackOutputs {
subnetIds: pulumi.Output<string>[]
}
export default async function(): Promise<StackOutputs> {
// Do everything here including awaiting
return {
subnetIds: someSubnets.map(subnet => subnet.id)
};
}
big-piano-35669
07/09/2018, 4:47 PMstocky-spoon-28903
07/09/2018, 5:16 PM