diff --git a/aws-ts-appsync/iam.ts b/aws-ts-appsync/iam.ts index 929c01c41..700c256e8 100644 --- a/aws-ts-appsync/iam.ts +++ b/aws-ts-appsync/iam.ts @@ -3,18 +3,16 @@ import * as aws from "@pulumi/aws"; export function createIamRole(name: string, table: aws.dynamodb.Table) { const role = new aws.iam.Role(`${name}-role`, { - assumeRolePolicy: pulumi.output( - aws.iam.getPolicyDocument({ + assumeRolePolicy: aws.iam.getPolicyDocument({ statements: [{ actions: ["sts:AssumeRole"], principals: [{ - identifiers: ["appsync.amazonaws.com"], + identifiers: ["appsync.amazonaws.com"], type: "Service", }], effect: "Allow", }], - }) - ).apply(r => r.json), + }).json, }); const policy = new aws.iam.Policy(`${name}-policy`, { @@ -24,8 +22,8 @@ export function createIamRole(name: string, table: aws.dynamodb.Table) { resources: [arn], effect: "Allow", }], - })).apply(r => r.json), - }); + })).json, + }); new aws.iam.RolePolicyAttachment(`${name}-rpa`, { role: role, diff --git a/aws-ts-ruby-on-rails/index.ts b/aws-ts-ruby-on-rails/index.ts index ab984114e..837f9f666 100644 --- a/aws-ts-ruby-on-rails/index.ts +++ b/aws-ts-ruby-on-rails/index.ts @@ -13,7 +13,7 @@ const webSg = new aws.ec2.SecurityGroup("webServerSecurityGroup", { ], }); -const amiId = pulumi.output(aws.getAmi({ +const amiId = aws.getAmi({ filters: [ { name: "name", @@ -26,7 +26,7 @@ const amiId = pulumi.output(aws.getAmi({ ], mostRecent: true, owners: ["137112412989"], -})); +}); const webServer = new aws.ec2.Instance("webServer", { ami: amiId.id, diff --git a/aws-ts-stackreference/team/index.ts b/aws-ts-stackreference/team/index.ts index e627f5d3e..90b65bdbd 100644 --- a/aws-ts-stackreference/team/index.ts +++ b/aws-ts-stackreference/team/index.ts @@ -25,7 +25,7 @@ const amiId = aws.getAmi({ { name: "owner-id", values: ["099720109477"] }, // Ubuntu { name: "name", values: ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"] }, ], -}).then(x => x.id); +}).id; const instance = new aws.ec2.Instance("tagged", { ami: amiId, diff --git a/aws-ts-static-website/index.ts b/aws-ts-static-website/index.ts index 2f419737c..adfd02726 100644 --- a/aws-ts-static-website/index.ts +++ b/aws-ts-static-website/index.ts @@ -96,7 +96,7 @@ if (config.certificateArn === undefined) { }, { provider: eastRegion }); const domainParts = getDomainAndSubdomain(config.targetDomain); - const hostedZoneId = aws.route53.getZone({ name: domainParts.parentDomain }).then(zone => zone.id); + const hostedZoneId = aws.route53.getZone({ name: domainParts.parentDomain }).id; /** * Create a DNS record to prove that we _own_ the domain we're requesting a certificate for. @@ -225,10 +225,10 @@ function getDomainAndSubdomain(domain: string): { subdomain: string, parentDomai } // Creates a new Route53 DNS record pointing the domain to the CloudFront distribution. -async function createAliasRecord( - targetDomain: string, distribution: aws.cloudfront.Distribution): Promise { +function createAliasRecord( + targetDomain: string, distribution: aws.cloudfront.Distribution): aws.route53.Record { const domainParts = getDomainAndSubdomain(targetDomain); - const hostedZone = await aws.route53.getZone({ name: domainParts.parentDomain }); + const hostedZone = aws.route53.getZone({ name: domainParts.parentDomain }); return new aws.route53.Record( targetDomain, { diff --git a/aws-ts-twitter-athena/index.ts b/aws-ts-twitter-athena/index.ts index b6e953fb1..0eef7fc9b 100644 --- a/aws-ts-twitter-athena/index.ts +++ b/aws-ts-twitter-athena/index.ts @@ -35,7 +35,7 @@ let handler = eventRule.onEvent("on-timer-event", async() => { access_token_key: accessTokenKey, access_token_secret: accessTokenSecret, }); - + const tweets = await new Promise((resolve, reject) => { client.get('search/tweets', {q: twitterQuery, count: 100}, function(error: any, tweets: any, response: any) { if (error) { @@ -44,17 +44,17 @@ let handler = eventRule.onEvent("on-timer-event", async() => { let statuses = tweets.statuses; console.log(`Got ${statuses.length} statuses.`); - + let results = statuses.map((s: any) => { let user = s.user.screen_name; - - return JSON.stringify({ + + return JSON.stringify({ created_at: s.created_at, - id: s.id_str, - text: s.text, + id: s.id_str, + text: s.text, user: user, hashtags: s.entities.hashtags, - followers: s.user.followers_count, + followers: s.user.followers_count, isVerified: s.user.verified, isRetweet: s.retweeted_status != null, url: `https://twitter.com/${user}/status/${s.id_str}`, @@ -66,7 +66,7 @@ let handler = eventRule.onEvent("on-timer-event", async() => { }); console.log(`Got ${tweets.length} tweets from Twitter for query ${twitterQuery}`); - + let filename = `${outputFolder}/${Date.now()}`; let contents = Buffer.from(tweets.join("\n"), "utf8"); @@ -79,11 +79,11 @@ let handler = eventRule.onEvent("on-timer-event", async() => { }); // athena setup -let athena = new aws.athena.Database("tweets_database", - { name: "tweets_database", bucket: bucket.id, forceDestroy: true } +let athena = new aws.athena.Database("tweets_database_1", + { name: "tweets_database_1", bucket: bucket.id, forceDestroy: true } ); -// Sadly, there isn't support for Athena tables in Terraform. +// Sadly, there isn't support for Athena tables in Terraform. // See https://github.com/terraform-providers/terraform-provider-aws/pull/1893#issuecomment-351300973 // So, we'll instead create a query for the table definition function createTableQuery(bucket: string) { @@ -101,9 +101,9 @@ function createTableQuery(bucket: string) { LOCATION 's3://${bucket}/${outputFolder}/';`; } -let topUsersQuery = - `select distinct user, followers, text, url - from tweets +let topUsersQuery = + `select distinct user, followers, text, url + from tweets where isRetweet = false and followers > 1000 order by followers desc`; @@ -121,4 +121,4 @@ function getQueryUri(queryId: string) { exports.bucketName = bucketName exports.athenaDatabase = athena.id; exports.topUsersQueryUri = topUsersAthenaQuery.id.apply(getQueryUri); -exports.createTableQueryUri = createTableAthenaQuery.id.apply(getQueryUri); +exports.createTableQueryUri = createTableAthenaQuery.id.apply(getQueryUri); diff --git a/azure-ts-msi-keyvault-rbac/index.ts b/azure-ts-msi-keyvault-rbac/index.ts index 6ffc08c55..cd905b3b5 100644 --- a/azure-ts-msi-keyvault-rbac/index.ts +++ b/azure-ts-msi-keyvault-rbac/index.ts @@ -69,16 +69,15 @@ const blob = new azure.storage.ZipBlob("zip", { content: new pulumi.asset.FileArchive("./webapp/bin/Debug/netcoreapp2.2/publish") }); -const clientConfig = pulumi.output(azure.core.getClientConfig({})); -const tenantId = clientConfig.apply(c => c.tenantId); - -const currentPrincipal = clientConfig.apply(c => - // Currently, only service principal ID is available in the context. If we are provided the principle in the config, then - // just use it. Otherwise, if logged in with a user, find their ID via Azure CLI. - // see https://github.com/terraform-providers/terraform-provider-azurerm/issues/3234 - c.servicePrincipalObjectId !== "" - ? c.servicePrincipalObjectId - : JSON.parse(execSync("az ad signed-in-user show --query objectId").toString())); +const clientConfig = azure.core.getClientConfig({}); +const tenantId = clientConfig.tenantId; + +// Currently, only service principal ID is available in the context. If we are provided the +// principle in the config, then just use it. Otherwise, if logged in with a user, find their ID +// via Azure CLI. see https://github.com/terraform-providers/terraform-provider-azurerm/issues/3234 +const currentPrincipal = clientConfig.servicePrincipalObjectId !== "" + ? clientConfig.servicePrincipalObjectId + : JSON.parse(execSync("az ad signed-in-user show --query objectId").toString()); // Key Vault to store secrets (e.g. Blob URL with SAS) const vault = new azure.keyvault.KeyVault("vault", { diff --git a/azure-ts-webserver-component/webserver.ts b/azure-ts-webserver-component/webserver.ts index 0f4b8dcb5..60a99d8cf 100644 --- a/azure-ts-webserver-component/webserver.ts +++ b/azure-ts-webserver-component/webserver.ts @@ -65,8 +65,8 @@ 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(async d => { - const ip = await azure.network.getPublicIP({ name: d.name, resourceGroupName: d.resourceGroupName }); + return ready.apply(d => { + const ip = azure.network.getPublicIP({ name: d.name, resourceGroupName: d.resourceGroupName }); return ip.ipAddress; }); } diff --git a/azure-ts-webserver/index.ts b/azure-ts-webserver/index.ts index e76f3f9a8..c0a230798 100644 --- a/azure-ts-webserver/index.ts +++ b/azure-ts-webserver/index.ts @@ -74,7 +74,7 @@ nohup python -m SimpleHTTPServer 80 &`, // resource to create, and then lookup the IP address again to report its public IP. const done = pulumi.all({ _: vm.id, name: publicIp.name, resourceGroupName: publicIp.resourceGroupName }); -export const ipAddress = done.apply(async d => { - const ip = await azure.network.getPublicIP({ name: d.name, resourceGroupName: d.resourceGroupName }); +export const ipAddress = done.apply(d => { + const ip = azure.network.getPublicIP({ name: d.name, resourceGroupName: d.resourceGroupName }); return ip.ipAddress; }); diff --git a/cloud-js-twitter-athena/index.js b/cloud-js-twitter-athena/index.js index 33eaa0e16..ed34bba75 100644 --- a/cloud-js-twitter-athena/index.js +++ b/cloud-js-twitter-athena/index.js @@ -22,20 +22,20 @@ cloud.timer.interval("twitter-search-timer", { minutes: 2 }, async() => { access_token_key: accessTokenKey, access_token_secret: accessTokenSecret, }); - + client.get('search/tweets', {q: twitterQuery, count: 100}, function(error, tweets, response) { let statuses = tweets.statuses; let results = statuses.map(s => { let user = s.user.screen_name; - - return JSON.stringify({ + + return JSON.stringify({ created_at: s.created_at, - id: s.id_str, - text: s.text, + id: s.id_str, + text: s.text, user: user, hashtags: s.entities.hashtags, - followers: s.user.followers_count, + followers: s.user.followers_count, isVerified: s.user.verified, isRetweet: s.retweeted_status != null, url: `https://twitter.com/${user}/status/${s.id_str}`, @@ -48,15 +48,15 @@ cloud.timer.interval("twitter-search-timer", { minutes: 2 }, async() => { let contents = Buffer.from(results.join("\n"), "utf8"); bucket.put(filename, contents); - }); + }); }); // athena setup -let athena = new aws.athena.Database("tweets_database", - { name: "tweets_database", bucket: bucket.bucket.id, forceDestroy: true } +let athena = new aws.athena.Database("tweets_database_2", + { name: "tweets_database_2", bucket: bucket.bucket.id, forceDestroy: true } ); -// Sadly, there isn't support for Athena tables in Terraform. +// Sadly, there isn't support for Athena tables in Terraform. // See https://github.com/terraform-providers/terraform-provider-aws/pull/1893#issuecomment-351300973 // So, we'll instead create a query for the table definition function createTableQuery(bucket) { @@ -74,9 +74,9 @@ function createTableQuery(bucket) { LOCATION 's3://${bucket}/${outputFolder}/';`; } -let topUsersQuery = - `select distinct user, followers, text, url - from tweets +let topUsersQuery = + `select distinct user, followers, text, url + from tweets where isRetweet = false and followers > 1000 order by followers desc`; @@ -96,4 +96,4 @@ function getQueryUri(queryId) { exports.bucketName = bucketName exports.athenaDatabase = athena.id; exports.topUsersQueryUri = topUsersAthenaQuery.id.apply(getQueryUri); -exports.createTableQueryUri = createTableAthenaQuery.id.apply(getQueryUri); +exports.createTableQueryUri = createTableAthenaQuery.id.apply(getQueryUri); diff --git a/kubernetes-ts-multicloud/gke.ts b/kubernetes-ts-multicloud/gke.ts index fcf3e8130..423183556 100644 --- a/kubernetes-ts-multicloud/gke.ts +++ b/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().then(v => v.latestMasterVersion); + const engineVersion = gcp.container.getEngineVersions().latestMasterVersion; // Generate a strong password for the Kubernetes cluster. const password = new random.RandomString("password", {