Make all JS/TS invokes async
This standardizes all data source calls to pass `async: true` to avoid potential for hangs.  See
MODIFY
aws-js-webserver-component/webserver.js
aws-js-webserver-component/webserver.js
@@ -4,13 +4,13 @@ const pulumi = require("@pulumi/pulumi");
const aws = require("@pulumi/aws");
// Get the id for the latest Amazon Linux AMI
-let ami = pulumi.output(aws.getAmi({
+let ami = aws.getAmi({
filters: [
{ name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] },
],
owners: ["137112412989"], // Amazon
mostRecent: true,
-})).apply(result => result.id);
+}, { async: true }).then(result => result.id);
// create a new security group for port 80
let group = new aws.ec2.SecurityGroup("web-secgrp", {

MODIFY
aws-js-webserver/index.js
aws-js-webserver/index.js
@@ -6,13 +6,13 @@ const aws = require("@pulumi/aws");
let size = "t2.micro"; // t2.micro is available in the AWS free tier
// Get the id for the latest Amazon Linux AMI
-let ami = pulumi.output(aws.getAmi({
+let ami = aws.getAmi({
filters: [
{ name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] },
],
owners: ["137112412989"], // Amazon
mostRecent: true,
-})).apply(result => result.id);
+}, { async: true }).then(result => result.id);
// create a new security group for port 80
let group = new aws.ec2.SecurityGroup("web-secgrp", {

MODIFY
aws-stackreference-architecture/networking/src/index.ts
aws-stackreference-architecture/networking/src/index.ts
@@ -13,7 +13,7 @@ async function main() {
};
const availabilityZones = aws.getAvailabilityZones({
state: "available",
- });
+ }, { async: true });
const appVpc = new Vpc("app-vpc", {
description: `${baseTags.ManagedBy} App VPC`,

MODIFY
aws-stackreference-architecture/networking/src/vpc.ts
aws-stackreference-architecture/networking/src/vpc.ts
@@ -261,7 +261,7 @@ export class Vpc extends ComponentResource {
let autoAccept = false;
let peerOwner = args.peerOwnerId;
if (!args.peerOwnerId) {
- peerOwner = output(aws.getCallerIdentity()).apply(i => i.accountId);
+ peerOwner = aws.getCallerIdentity({ async: true }).then(i => i.accountId);
autoAccept = true;
}
const peerName = args.peerVpc.name;

MODIFY
aws-ts-appsync/iam.ts
aws-ts-appsync/iam.ts
@@ -14,7 +14,7 @@ export function createIamRole(name: string, table: aws.dynamodb.Table) {
}],
effect: "Allow",
}],
- }).json,
+ }, { async: true }).then(doc => doc.json),
});
const policy = new aws.iam.Policy(`${name}-policy`, {
@@ -24,7 +24,7 @@ export function createIamRole(name: string, table: aws.dynamodb.Table) {
resources: [arn],
effect: "Allow",
}],
- })).json,
+ }, { async: true }).then(doc => doc.json)),
});
const attachment = new aws.iam.RolePolicyAttachment(`${name}-rpa`, {

MODIFY
aws-ts-ruby-on-rails/index.ts
aws-ts-ruby-on-rails/index.ts
@@ -28,10 +28,10 @@ const amiId = aws.getAmi({
],
mostRecent: true,
owners: ["137112412989"],
-});
+}, { async: true }).then(ami => ami.id);
const webServer = new aws.ec2.Instance("webServer", {
- ami: amiId.id,
+ ami: amiId,
instanceType: config.instanceType,
securityGroups: [ webSg.name ],
userData: createUserData(

MODIFY
aws-ts-stackreference/team/index.ts
aws-ts-stackreference/team/index.ts
@@ -21,16 +21,16 @@ const combinedTags = {
"Managed By": "Pulumi",
};
-const ami = aws.getAmi({
+const amiId = aws.getAmi({
owners: ["099720109477"], // Ubuntu
mostRecent: true,
filters: [
{ name: "name", values: ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"] },
],
-});
+}, { async: true }).then(ami => ami.id);
const instance = new aws.ec2.Instance("tagged", {
- ami: ami.id,
+ ami: amiId,
instanceType: "t2.medium",
tags: combinedTags,
});

MODIFY
aws-ts-static-website/index.ts
aws-ts-static-website/index.ts
@@ -98,7 +98,7 @@ if (config.certificateArn === undefined) {
}, { provider: eastRegion });
const domainParts = getDomainAndSubdomain(config.targetDomain);
- const hostedZoneId = aws.route53.getZone({ name: domainParts.parentDomain }).id;
+ const hostedZoneId = aws.route53.getZone({ name: domainParts.parentDomain }, { async: true }).then(zone => zone.zoneId);
/**
* Create a DNS record to prove that we _own_ the domain we're requesting a certificate for.
@@ -230,12 +230,12 @@ function getDomainAndSubdomain(domain: string): { subdomain: string, parentDomai
function createAliasRecord(
targetDomain: string, distribution: aws.cloudfront.Distribution): aws.route53.Record {
const domainParts = getDomainAndSubdomain(targetDomain);
- const hostedZone = aws.route53.getZone({ name: domainParts.parentDomain });
+ const hostedZoneId = aws.route53.getZone({ name: domainParts.parentDomain }, { async: true }).then(zone => zone.zoneId);
return new aws.route53.Record(
targetDomain,
{
name: domainParts.subdomain,
- zoneId: hostedZone.zoneId,
+ zoneId: hostedZoneId,
type: "A",
aliases: [
{

MODIFY
azure-js-webserver/index.js
azure-js-webserver/index.js
@@ -74,5 +74,5 @@ exports.publicIP = pulumi.all({ id: vm.id, name: publicIP.name, resourceGroupNam
azure.network.getPublicIP({
name: ip.name,
resourceGroupName: ip.resourceGroupName,
- }).then(ip => ip.ipAddress)
+ }, { async: true }).then(ip => ip.ipAddress)
);

MODIFY
azure-ts-msi-keyvault-rbac/index.ts
azure-ts-msi-keyvault-rbac/index.ts
@@ -67,9 +67,9 @@ const blob = new azure.storage.ZipBlob("zip", {
content: new pulumi.asset.FileArchive("./webapp/bin/Debug/netcoreapp2.2/publish"),
});
-const clientConfig = azure.core.getClientConfig({});
-const tenantId = clientConfig.tenantId;
-const currentPrincipal = clientConfig.objectId;
+const clientConfig = azure.core.getClientConfig({ async: true });
+const tenantId = clientConfig.then(config => config.tenantId);
+const currentPrincipal = clientConfig.then(config => config.objectId);
// Key Vault to store secrets (e.g. Blob URL with SAS)
const vault = new azure.keyvault.KeyVault("vault", {

MODIFY
azure-ts-webserver-component/webserver.ts
azure-ts-webserver-component/webserver.ts
@@ -67,10 +67,11 @@ export class WebServer extends pulumi.ComponentResource {
// The public IP address is not allocated until the VM is running, so wait for that
// resource to create, and then lookup the IP address again to report its public IP.
const ready = pulumi.all({ _: this.vm.id, name: this.publicIp.name, resourceGroupName: this.publicIp.resourceGroupName });
- return ready.apply(d => {
- const ip = azure.network.getPublicIP({ name: d.name, resourceGroupName: d.resourceGroupName });
- return ip.ipAddress;
- });
+ return ready.apply(d =>
+ azure.network.getPublicIP({
+ name: d.name,
+ resourceGroupName: d.resourceGroupName,
+ }, { async: true }).then(ip => ip.ipAddress));
}
}

MODIFY
azure-ts-webserver/index.ts
azure-ts-webserver/index.ts
@@ -72,6 +72,8 @@ nohup python -m SimpleHTTPServer 80 &`,
const done = pulumi.all({ _: vm.id, name: publicIp.name, resourceGroupName: publicIp.resourceGroupName });
export const ipAddress = done.apply(d => {
- const ip = azure.network.getPublicIP({ name: d.name, resourceGroupName: d.resourceGroupName });
- return ip.ipAddress;
+ return azure.network.getPublicIP({
+ name: d.name,
+ resourceGroupName: d.resourceGroupName,
+ }, { async: true }).then(ip => ip.ipAddress);
});

MODIFY
f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts
f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts
@@ -11,7 +11,7 @@ const ubuntuAmiId = aws.getAmi({
mostRecent: true,
nameRegex: "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
owners: ["099720109477"],
-}).then(ami => ami.id);
+}, { async: true }).then(ami => ami.id);
const nginxUserData =
`#!/bin/bash

MODIFY
kubernetes-ts-multicloud/aks.ts
kubernetes-ts-multicloud/aks.ts
@@ -98,7 +98,7 @@ export class AksCluster extends pulumi.ComponentResource {
clientId: adApp.applicationId,
clientSecret: adSpPassword.value,
},
- kubernetesVersion: "1.13.5",
+ kubernetesVersion: "1.15.5",
roleBasedAccessControl: {enabled: true},
networkProfile: {
networkPlugin: "azure",

MODIFY
kubernetes-ts-multicloud/gke.ts
kubernetes-ts-multicloud/gke.ts
@@ -26,7 +26,7 @@ export class GkeCluster extends pulumi.ComponentResource {
super("examples:kubernetes-ts-multicloud:GkeCluster", name, {}, opts);
// Find the latest engine version.
- const engineVersion = gcp.container.getEngineVersions().latestMasterVersion;
+ const engineVersion = gcp.container.getEngineVersions({}, { async: true }).then(v => v.latestMasterVersion);
// Generate a strong password for the Kubernetes cluster.
const password = new random.RandomPassword("password", {

MODIFY
linode-js-webserver/index.ts
linode-js-webserver/index.ts
@@ -9,7 +9,7 @@ const startupScript = `#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &`;
-const profile = pulumi.output(linode.getProfile());
+const profile = pulumi.output(linode.getProfile({ async: true }));
const stackscript = new linode.StackScript("simple-server", {
label: "simple-server",

Make all JS/TS invokes async (#502)

This standardizes all data source calls to pass `async: true` to avoid potential for hangs.  See https://github.com/pulumi/pulumi/issues/3528.