Skip to content

Commit

Permalink
Add tests for examples (pulumi#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Mar 8, 2019
1 parent 98abe30 commit 09bfb69
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 123 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ensure:
only_build:

only_test:
go test ./misc/test/... --timeout 1h -v -count=1 -short
go test ./misc/test/... --timeout 2h -v -count=1 -short -parallel 8

# The travis_* targets are entrypoints for CI.
.PHONY: travis_cron travis_push travis_pull_request travis_api
Expand Down
7 changes: 4 additions & 3 deletions aws-js-webserver-component/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

const aws = require("@pulumi/aws");

let ami = "ami-7172b611" // AMI for Amazon Linux in us-west-2 (Oregon)
// let ami = "ami-7172b611" // AMI for Amazon Linux in us-west-2 (Oregon)
let ami = "ami-c55673a0" // AMI for us-east-2 (Ohio)
// let ami = "ami-6869aa05" // AMI for us-east-1 (Virginia)
// let ami = "ami-31490d51" // AMI for us-west-1 (California)
// let ami = "ami-f9dd458a" // AMI for eu-west-1 (Ireland)
// let ami = "ami-ea26ce85" // AMI for eu-central-1 (Frankfurt)

// create a new security group for port 80
let group = new aws.ec2.SecurityGroup("web-secgrp", {
let group = new aws.ec2.SecurityGroup("web-secgrp", {
description: "Enable HTTP access",
ingress: [
{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
],
});

// (optional) create a simple web server using the startup script for the instance
let userData =
let userData =
`#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &`;
Expand Down
7 changes: 4 additions & 3 deletions aws-js-webserver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ const aws = require("@pulumi/aws");

let size = "t2.micro"; // t2.micro is available in the AWS free tier

let ami = "ami-7172b611" // AMI for Amazon Linux in us-west-2 (Oregon)
// let ami = "ami-7172b611" // AMI for Amazon Linux in us-west-2 (Oregon)
let ami = "ami-c55673a0" // AMI for us-east-2 (Ohio)
// let ami = "ami-6869aa05" // AMI for us-east-1 (Virginia)
// let ami = "ami-31490d51" // AMI for us-west-1 (California)
// let ami = "ami-f9dd458a" // AMI for eu-west-1 (Ireland)
// let ami = "ami-ea26ce85" // AMI for eu-central-1 (Frankfurt)

// create a new security group for port 80
let group = new aws.ec2.SecurityGroup("web-secgrp", {
let group = new aws.ec2.SecurityGroup("web-secgrp", {
ingress: [
{ protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
],
});

// (optional) create a simple web server using the startup script for the instance
let userData =
let userData =
`#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &`;
Expand Down
3 changes: 0 additions & 3 deletions aws-ts-airflow/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ template:
aws:region:
description: The AWS region to deploy into
default: us-east-1
cloud-aws:ecsAutoCluster:
description: Automatically provision ECS Cluster?
default: true
airflow:dbPassword:
description: The desired RDS password
secret: true
3 changes: 2 additions & 1 deletion aws-ts-airflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let vpc = awsx.ec2.Vpc.getDefault();
// Create a basic cluster and autoscaling group
let cluster = new awsx.ecs.Cluster("airflow", { vpc });
let autoScalingGroup = cluster.createAutoScalingGroup("airflow", {
subnetIds: vpc.publicSubnetIds,
templateParameters: {
minSize: 20,
},
Expand Down Expand Up @@ -45,7 +46,7 @@ let cacheSubnets = new aws.elasticache.SubnetGroup("cachesubnets", {
});

let cacheCluster = new aws.elasticache.Cluster("cachecluster", {
clusterId: "cache-" + pulumi.getStack(),
clusterId: `cache-${pulumi.getStack()}`.substr(0, 20),
engine: "redis",

nodeType: "cache.t2.micro",
Expand Down
100 changes: 50 additions & 50 deletions aws-ts-resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Athena
const databaseBucket = new aws.s3.Bucket("mydatabasebucket");
const database = new aws.athena.Database("mydatabase", {
name: "mydatabase",
bucket: databaseBucket.bucket
});
// const databaseBucket = new aws.s3.Bucket("mydatabasebucket");
// const database = new aws.athena.Database("mydatabase", {
// name: "mydatabase",
// bucket: databaseBucket.bucket
// });

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

// CloudWatch
const dashboard = new aws.cloudwatch.Dashboard("mydashboard", {
Expand Down Expand Up @@ -235,54 +235,54 @@ const user = new aws.iam.User("myuser");

const group = new aws.iam.Group("mygroup");

const policyAttachment = new aws.iam.PolicyAttachment("mypolicyattachment", {
users: [user],
groups: [group],
roles: [role],
policyArn: policy.arn
});
// const policyAttachment = new aws.iam.PolicyAttachment("mypolicyattachment", {
// users: [user],
// groups: [group],
// roles: [role],
// policyArn: policy.arn
// });

// Kinesis
const stream = new aws.kinesis.Stream("mystream", {
shardCount: 1
});

// S3
const bucket = new aws.s3.Bucket("my-bucket");

const bucketMetric = new aws.s3.BucketMetric("my-bucket-metric", {
bucket: bucket.bucket
});

const bucketNotification = new aws.s3.BucketNotification("my-bucket-notification", {
bucket: bucket.bucket
});

const bucketObject = new aws.s3.BucketObject("my-bucket-object", {
bucket: bucket.bucket,
content: "hello world"
});

const bucketPolicy = new aws.s3.BucketPolicy("my-bucket-policy", {
bucket: bucket.bucket,
policy: bucket.bucket.apply(publicReadPolicyForBucket)
})

function publicReadPolicyForBucket(bucketName: string) {
return JSON.stringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: "*",
Action: [
"s3:GetObject"
],
Resource: [
`arn:aws:s3:::${bucketName}/*` // policy refers to bucket name explicitly
]
}]
});
}
// const bucket = new aws.s3.Bucket("my-bucket");

// const bucketMetric = new aws.s3.BucketMetric("my-bucket-metric", {
// bucket: bucket.bucket
// });

// const bucketNotification = new aws.s3.BucketNotification("my-bucket-notification", {
// bucket: bucket.bucket
// });

// const bucketObject = new aws.s3.BucketObject("my-bucket-object", {
// bucket: bucket.bucket,
// content: "hello world"
// });

// const bucketPolicy = new aws.s3.BucketPolicy("my-bucket-policy", {
// bucket: bucket.bucket,
// policy: bucket.bucket.apply(publicReadPolicyForBucket)
// })

// function publicReadPolicyForBucket(bucketName: string) {
// return JSON.stringify({
// Version: "2012-10-17",
// Statement: [{
// Effect: "Allow",
// Principal: "*",
// Action: [
// "s3:GetObject"
// ],
// Resource: [
// `arn:aws:s3:::${bucketName}/*` // policy refers to bucket name explicitly
// ]
// }]
// });
// }

// SQS
const queue = new aws.sqs.Queue("myqueue");
Expand Down
Loading

0 comments on commit 09bfb69

Please sign in to comment.