Skip to content

Commit

Permalink
Use the new 0.17 api (pulumi#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Mar 6, 2019
1 parent 17a1450 commit 735a711
Show file tree
Hide file tree
Showing 31 changed files with 129 additions and 123 deletions.
3 changes: 2 additions & 1 deletion aws-js-containers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const pulumi = require("@pulumi/pulumi");
const awsx = require("@pulumi/awsx");

let cluster = new awsx.ecs.Cluster("example", { });
Expand All @@ -17,4 +18,4 @@ let service = new awsx.ecs.FargateService("nginx", {
});

// export just the hostname property of the container frontend
exports.hostname = listener.endpoint.apply(e => `http:https://${e.hostname}`);
exports.hostname = pulumi.interpolate `http:https://${listener.endpoint.hostname}`;
4 changes: 3 additions & 1 deletion aws-js-webserver-component/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const pulumi = require("@pulumi/pulumi");

const webserver = require("./webserver.js");

let webInstance = webserver.createInstance("web-server-www", "t2.nano");
let appInstance = webserver.createInstance("web-server-app", "t2.micro");

exports.webUrl = webInstance.publicDns.apply(dns => `http:https://${dns}`); // apply transformation to output property
exports.webUrl = pulumi.interpolate `http:https://${webInstance.publicDns}`;
6 changes: 3 additions & 3 deletions aws-ts-airflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let cacheCluster = new aws.elasticache.Cluster("cachecluster", {
securityGroupIds: securityGroupIds,
});

let hosts = pulumi.all([db.endpoint.apply(e => e.split(":")[0]), cacheCluster.cacheNodes.apply(n => n[0].address)]);
let hosts = pulumi.all([db.endpoint.apply(e => e.split(":")[0]), cacheCluster.cacheNodes[0].address]);
let environment = hosts.apply(([postgresHost, redisHost]) => [
{ name: "POSTGRES_HOST", value: postgresHost },
{ name: "POSTGRES_PASSWORD", value: dbPassword },
Expand Down Expand Up @@ -130,5 +130,5 @@ let airflowWorkers = new awsx.ecs.EC2Service("airflowworkers", {
},
});

export let airflowEndpoint = airflowControllerListener.endpoint().apply(e => e.hostname);
export let flowerEndpoint = airflowerListener.endpoint().apply(e => e.hostname);
export let airflowEndpoint = airflowControllerListener.endpoint().hostname;
export let flowerEndpoint = airflowerListener.endpoint().hostname;
3 changes: 2 additions & 1 deletion aws-ts-containers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as pulumi from "@pulumi/pulumi";
import * as awsx from "@pulumi/awsx";

// Create an elastic network listener to listen for requests and route them to the container.
Expand All @@ -21,4 +22,4 @@ let service = new awsx.ecs.FargateService("nginx", {
});

// export just the hostname property of the container frontend
export const hostname = listener.endpoint().apply(e => `http:https://${e.hostname}`);
export const hostname = pulumi.interpolate `http:https://${listener.endpoint.hostname}`;
6 changes: 3 additions & 3 deletions aws-ts-eks-hello-world/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const kubeconfig = cluster.kubeconfig
const ns = new k8s.core.v1.Namespace(name, {}, { provider: cluster.provider });

// Export the Namespace name
export const namespaceName = ns.metadata.apply(m => m.name);
export const namespaceName = ns.metadata.name;

// Create a NGINX Deployment
const appLabels = { appClass: name };
Expand Down Expand Up @@ -60,7 +60,7 @@ const deployment = new k8s.apps.v1.Deployment(name,
);

// Export the Deployment name
export const deploymentName = deployment.metadata.apply(m => m.name);
export const deploymentName = deployment.metadata.name;

// Create a LoadBalancer Service for the NGINX Deployment
const service = new k8s.core.v1.Service(name,
Expand All @@ -81,5 +81,5 @@ const service = new k8s.core.v1.Service(name,
);

// Export the Service name and public LoadBalancer Endpoint
export const serviceName = service.metadata.apply(m => m.name);
export const serviceName = service.metadata.name;
export const serviceHostname = service.status.apply(s => s.loadBalancer.ingress[0].hostname)
2 changes: 1 addition & 1 deletion aws-ts-resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const database = new aws.athena.Database("mydatabase", {

const namedQuery = new aws.athena.NamedQuery("mynamedquery", {
database: database.id,
query: database.id.apply(n => `SELECT * FROM ${n} limit 10;`)
query: pulumi.interpolate `SELECT * FROM ${database.id} limit 10;`,
});

// CloudWatch
Expand Down
5 changes: 3 additions & 2 deletions aws-ts-ruby-on-rails/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as config from "./config";
import { getLinuxAmi } from "pawsami";
Expand Down Expand Up @@ -50,7 +51,7 @@ const webServer = new aws.ec2.Instance("webServer", {
},
},
services: {
"sysvinit": {
"sysvinit": {
"mysqld": { enabled: true, ensureRunning: true },
},
},
Expand Down Expand Up @@ -114,4 +115,4 @@ const webServer = new aws.ec2.Instance("webServer", {
export let vmIP = webServer.publicIp;

// Export the URL for our newly created Rails application.
export let websiteURL = webServer.publicDns.apply(url => `http:https://${url}/notes`);
export let websiteURL = pulumi.interpolate `http:https://${webServer.publicDns}/notes`;
14 changes: 7 additions & 7 deletions aws-ts-serverless-raw/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.

import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// The location of the built dotnet2.0 application to deploy
// The location of the built dotnet2.0 application to deploy
let dotNetApplicationPublishFolder = "./app/bin/Debug/netcoreapp2.0/publish";
let dotNetApplicationEntryPoint = "app::app.Functions::GetAsync";
// The stage name to use for the API Gateway URL
Expand Down Expand Up @@ -58,7 +58,7 @@ let lambda = new aws.lambda.Function("mylambda", {
timeout: 300,
handler: dotNetApplicationEntryPoint,
role: role.arn,
environment: {
environment: {
variables: {
"COUNTER_TABLE": counterTable.name
}
Expand Down Expand Up @@ -105,11 +105,11 @@ let restApi = new aws.apigateway.RestApi("api", {
let deployment = new aws.apigateway.Deployment("api-deployment", {
restApi: restApi,
// Note: Set to empty to avoid creating an implicit stage, we'll create it explicitly below instead.
stageName: "",
stageName: "",
});

// Create a stage, which is an addressable instance of the Rest API. Set it to point at the latest deployment.
let stage = new aws.apigateway.Stage("api-stage", {
let stage = new aws.apigateway.Stage("api-stage", {
restApi: restApi,
deployment: deployment,
stageName: stageName
Expand All @@ -120,8 +120,8 @@ let invokePermission = new aws.lambda.Permission("api-lambda-permission", {
action: "lambda:invokeFunction",
function: lambda,
principal: "apigateway.amazonaws.com",
sourceArn: deployment.executionArn.apply(arn => arn + "*/*"),
sourceArn: pulumi.interpolate `${deployment.executionArn}*/*`,
});

// Export the https endpoint of the running Rest API
export let endpoint = deployment.invokeUrl.apply(url => url + stageName);
export let endpoint = pulumi.interpolate `${deployment.invokeUrl}${stageName}`;
22 changes: 11 additions & 11 deletions aws-ts-static-website/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

import * as fs from "fs";
import * as mime from "mime";
Expand Down Expand Up @@ -84,7 +84,7 @@ let certificateArn: pulumi.Input<string> = config.certificateArn!;
* Only provision a certificate (and related resources) if a certificateArn is _not_ provided via configuration.
*/
if (config.certificateArn === undefined) {

const eastRegion = new aws.Provider("east", {
region: "us-east-1", // Per AWS, ACM certificate must be in the us-east-1 region.
});
Expand All @@ -102,18 +102,18 @@ if (config.certificateArn === undefined) {
* See https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-validate-dns.html for more info.
*/
const certificateValidationDomain = new aws.route53.Record(`${config.targetDomain}-validation`, {
name: certificate.domainValidationOptions.apply(d => d[0].resourceRecordName),
name: certificate.domainValidationOptions[0].resourceRecordName,
zoneId: hostedZoneId,
type: certificate.domainValidationOptions.apply(d => d[0].resourceRecordType),
records: [certificate.domainValidationOptions.apply(d => d[0].resourceRecordValue)],
type: certificate.domainValidationOptions[0].resourceRecordType,
records: [certificate.domainValidationOptions[0].resourceRecordValue],
ttl: tenMinutes,
});

/**
* This is a _special_ resource that waits for ACM to complete validation via the DNS record
* checking for a status of "ISSUED" on the certificate itself. No actual resources are
* created (or updated or deleted).
*
* This is a _special_ resource that waits for ACM to complete validation via the DNS record
* checking for a status of "ISSUED" on the certificate itself. No actual resources are
* created (or updated or deleted).
*
* See https://www.terraform.io/docs/providers/aws/r/acm_certificate_validation.html for slightly more detail
* and https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_acm_certificate_validation.go
* for the actual implementation.
Expand All @@ -132,7 +132,7 @@ if (config.certificateArn === undefined) {
const distributionArgs: aws.cloudfront.DistributionArgs = {
enabled: true,
// Alternate aliases the CloudFront distribution can be reached at, in addition to https://xxxx.cloudfront.net.
// Required if you want to access the distribution via config.targetDomain as well.
// Required if you want to access the distribution via config.targetDomain as well.
aliases: [ config.targetDomain ],

// We only specify one origin for this distribution, the S3 content bucket.
Expand Down Expand Up @@ -248,7 +248,7 @@ const aRecord = createAliasRecord(config.targetDomain, cdn);

// Export properties from this stack. This prints them at the end of `pulumi up` and
// makes them easier to access from the pulumi.com.
export const contentBucketUri = contentBucket.bucket.apply(b => `s3:https://${b}`);
export const contentBucketUri = pulumi.interpolate `s3:https://${contentBucket.bucket}`;
export const contentBucketWebsiteEndpoint = contentBucket.websiteEndpoint;
export const cloudFrontDomain = cdn.domainName;
export const targetDomainEndpoint = `https://${config.targetDomain}/`;
3 changes: 2 additions & 1 deletion aws-ts-url-shortener-cache-http/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as cloud from "@pulumi/cloud-aws";
Expand Down Expand Up @@ -104,4 +105,4 @@ let httpServer = new cloud.HttpServer("urlshortener", () => {
return app;
});

export let endpointUrl = httpServer.url.apply(u => u + "index.html");
export let endpointUrl = pulumi.interpolate `${httpServer.url}index.html`;
12 changes: 6 additions & 6 deletions azure-ts-appservice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const username = "pulumi";

// Get the password to use for SQL from config.
const config = new pulumi.Config();
const pwd = config.require("sqlPassword");
const pwd = config.require("sqlPassword");

const sqlServer = new azure.sql.SqlServer(`${prefix}-sql`, {
...resourceGroupArgs,

administratorLogin: username,
administratorLoginPassword: pwd,
version: "12.0",
version: "12.0",
});

const database = new azure.sql.Database(`${prefix}-db`, {
Expand All @@ -93,11 +93,11 @@ const app = new azure.appservice.AppService(`${prefix}-as`, {

connectionStrings: [{
name: "db",
value:
pulumi.all([sqlServer.name, database.name]).apply(([server, db]) =>
value:
pulumi.all([sqlServer.name, database.name]).apply(([server, db]) =>
`Server=tcp:${server}.database.windows.net;initial catalog=${db};user ID=${username};password=${pwd};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;`),
type: "SQLAzure"
}]
}]
});

exports.endpoint = app.defaultSiteHostname.apply(n => `https://${n}`);
exports.endpoint = pulumi.interpolate `https://${app.defaultSiteHostname}`;
2 changes: 1 addition & 1 deletion azure-ts-arm-template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", {
});

// Finally, export the allocated storage account name.
export const storageAccountName = armDeployment.outputs.apply(outs => outs["storageAccountName"]);
export const storageAccountName = armDeployment.outputs["storageAccountName"];
3 changes: 2 additions & 1 deletion cloud-js-containers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const pulumi = require("@pulumi/pulumi");
const cloud = require("@pulumi/cloud-aws");

let service = new cloud.Service("pulumi-nginx", {
Expand All @@ -12,4 +13,4 @@ let service = new cloud.Service("pulumi-nginx", {
});

// export just the hostname property of the container frontend
exports.hostname = service.defaultEndpoint.apply(e => `http:https://${e.hostname}`);
exports.hostname = pulumi.interpolate `http:https://${service.defaultEndpoint.hostname}`;
2 changes: 1 addition & 1 deletion cloud-ts-url-shortener-cache-http/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Cache {
},
});

this.endpoint = this.redis.endpoints.apply(endpoints => endpoints.redis[6379]);
this.endpoint = this.redis.endpoints.redis[6379];
}

public get(key: string): Promise<string> {
Expand Down
3 changes: 2 additions & 1 deletion cloud-ts-url-shortener-cache-http/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.

import * as pulumi from "@pulumi/pulumi";
import * as cloud from "@pulumi/cloud";
import * as cache from "./cache";
import * as express from "express";
Expand Down Expand Up @@ -131,4 +132,4 @@ function staticRoutes(app: express.Express, path: string, root: string) {
}
}

export let endpointUrl = endpoint.url.apply(u => u + "index.html");
export let endpointUrl = pulumi.interpolate `${endpoint.url}index.html`;
2 changes: 1 addition & 1 deletion cloud-ts-url-shortener-cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Cache {
},
});

let endpoint = this.redis.endpoints.apply(endpoints => endpoints.redis[6379]);
let endpoint = this.redis.endpoints.redis[6379];
this.get = async (key: string) => {
let ep = (await endpoint).get();
console.log(`Getting key '${key}' on Redis@${ep.hostname}:${ep.port}`);
Expand Down
12 changes: 6 additions & 6 deletions cloud-ts-voting-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as cloud from "@pulumi/cloud";

// Get the password to use for Redis from config.
let config = new pulumi.Config();
let redisPassword = config.require("redisPassword");
let redisPassword = config.require("redisPassword");
let redisPort = 6379;

// The data layer for the application
Expand All @@ -21,7 +21,7 @@ let redisCache = new cloud.Service("voting-app-cache", {
},
});

let redisEndpoint = redisCache.endpoints.apply(endpoints => endpoints.redis[redisPort]);
let redisEndpoint = redisCache.endpoints.redis[redisPort];

// A custom container for the frontend, which is a Python Flask app
// Use the 'build' property to specify a folder that contains a Dockerfile.
Expand All @@ -31,10 +31,10 @@ let frontend = new cloud.Service("voting-app-frontend", {
votingAppFrontend: {
build: "./frontend", // path to the folder containing the Dockerfile
memory: 512,
ports: [{ port: 80 }],
environment: {
ports: [{ port: 80 }],
environment: {
// pass the Redis container info in environment variables
"REDIS": redisEndpoint.apply(e => e.hostname),
"REDIS": redisEndpoint.hostname,
"REDIS_PORT": redisEndpoint.apply(e => e.port.toString()),
"REDIS_PWD": redisPassword
}
Expand All @@ -43,4 +43,4 @@ let frontend = new cloud.Service("voting-app-frontend", {
});

// Export a variable that will be displayed during 'pulumi up'
export let frontendURL = frontend.endpoints.apply(e => e["votingAppFrontend"][80].hostname);
export let frontendURL = frontend.endpoints["votingAppFrontend"][80].hostname;
2 changes: 1 addition & 1 deletion f5bigip-ts-ltm-pool/f5bigip-ec2-instance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ const f5BigIpInstance = new aws.ec2.Instance("bigIp", {
vpcSecurityGroupIds: [firewall.id],
});

export const f5Address = f5BigIpInstance.publicIp.apply(x => `https://${x}:8443`);
export const f5Address = pulumi.interpolate `https://${f5BigIpInstance.publicIp}:8443`;
export const f5PrivateIp = f5BigIpInstance.privateIp;
2 changes: 1 addition & 1 deletion gcp-js-webserver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ const computeInstance = new gcp.compute.Instance("instance", {
}, { dependsOn: [computeFirewall] });

exports.instanceName = computeInstance.name;
exports.instanceIP = computeInstance.networkInterfaces.apply(ni => ni[0].accessConfigs[0].natIp);
exports.instanceIP = computeInstance.networkInterfaces[0].accessConfigs[0].natIp;
6 changes: 3 additions & 3 deletions gcp-ts-gke-hello-world/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const clusterProvider = new k8s.Provider(name, {
const ns = new k8s.core.v1.Namespace(name, {}, { provider: clusterProvider });

// Export the Namespace name
export const namespaceName = ns.metadata.apply(m => m.name);
export const namespaceName = ns.metadata.name;

// Create a NGINX Deployment
const appLabels = { appClass: name };
Expand Down Expand Up @@ -102,7 +102,7 @@ const deployment = new k8s.apps.v1.Deployment(name,
);

// Export the Deployment name
export const deploymentName = deployment.metadata.apply(m => m.name);
export const deploymentName = deployment.metadata.name;

// Create a LoadBalancer Service for the NGINX Deployment
const service = new k8s.core.v1.Service(name,
Expand All @@ -123,5 +123,5 @@ const service = new k8s.core.v1.Service(name,
);

// Export the Service name and public LoadBalancer endpoint
export const serviceName = service.metadata.apply(m => m.name);
export const serviceName = service.metadata.name;
export const servicePublicIP = service.status.apply(s => s.loadBalancer.ingress[0].ip)
6 changes: 3 additions & 3 deletions gcp-ts-k8s-ruby-on-rails-postgresql/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ const appDeployment = new k8s.apps.v1.Deployment("rails-deployment", {
},
}, { provider: cluster.provider });
const appService = new k8s.core.v1.Service("rails-service", {
metadata: { labels: appDeployment.metadata.apply(m => m.labels) },
metadata: { labels: appDeployment.metadata.labels },
spec: {
type: "LoadBalancer",
ports: [{ port: appPort, targetPort: appPort }],
selector: appDeployment.spec.apply(spec => spec.template.metadata.labels),
selector: appDeployment.spec.template.metadata.labels,
},
}, { provider: cluster.provider });

// Export the app deployment name so we can easily access it.
export let appName = appDeployment.metadata.apply(m => m.name);
export let appName = appDeployment.metadata.name;

// Export the service's IP address.
export let appAddress = appService.status.apply(s => `http:https://${s.loadBalancer.ingress[0].ip}:${appPort}`);
Expand Down
Loading

0 comments on commit 735a711

Please sign in to comment.