Adding Packet example for Py and Ts
MODIFY
misc/test/examples_test.go
misc/test/examples_test.go
@@ -943,6 +943,24 @@ func TestAccGcpTsServerlessRaw(t *testing.T) {
integration.ProgramTest(t, &test)
}
+func TestAccPacketPyWebserver(t *testing.T) {
+ test := getBaseOptions(t).
+ With(integration.ProgramTestOptions{
+ Dir: path.Join(getCwd(t), "..", "..", "packet-py-webserver"),
+ })
+
+ integration.ProgramTest(t, &test)
+}
+
+func TestAccPacketTsWebserver(t *testing.T) {
+ test := getBaseOptions(t).
+ With(integration.ProgramTestOptions{
+ Dir: path.Join(getCwd(t), "..", "..", "packet-ts-webserver"),
+ })
+
+ integration.ProgramTest(t, &test)
+}
+
func skipIfShort(t *testing.T) {
if testing.Short() {
t.Skip("skipping long-running test in short mode")

ADD
packet-py-webserver/.gitignore
+/bin/

ADD
packet-py-webserver/Pulumi.yaml
+name: packet-py-webserver
+description: A simple server on Packet.
+runtime: python

ADD
packet-py-webserver/README.md
+[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)
+
+# Packet Webserver
+
+This example demonstrates creating a webserver in Packet.net with Python
+
+# Running the Example
+
+After cloning this repo, `cd` into it and run these commands.
+
+1. Create a new stack, which is an isolated deployment target for this example:
+
+ ```bash
+ $ pulumi stack init
+ ```
+
+1. Install all of the dependencies for the application:
+
+ ```bash
+ $ npm install
+ ```
+
+1. Deploy everything with the `pulumi up` command. This provisions the webserver:
+
+ ```bash
+ $ pulumi up
+ ```
+
+1. After a couple minutes, your webserver will be ready.
+
+ ```bash
+ $ pulumi up
+ ...
+
+ Outputs:
+ + ip : "147.75.65.213"
+ + name: "new-vervet"
+ ```
+
+1. Once you are done, you can destroy all of the resources, and the stack:
+
+ ```bash
+ $ pulumi destroy
+ $ pulumi stack rm
+ ```

ADD
packet-py-webserver/__main__.py
+import pulumi_packet as packet
+import pulumi_random as random
+from pulumi import export
+
+random_host_name = random.RandomPet("hostname")
+random_project_name = random.RandomPet("projectname")
+
+project = packet.Project(
+ "project",
+ name=random_project_name.id,
+)
+
+vm = packet.Device(
+ "vm",
+ billing_cycle="hourly",
+ facility="ewr1",
+ hostname=random_host_name.id,
+ operating_system="coreos_stable",
+ plan="baremetal_0",
+ project_id=project.id,
+ ip_address_types=["public_ipv4"],
+)
+
+export('ip', vm.access_public_ipv4)
+export('name', vm.hostname)

ADD
packet-py-webserver/requirements.txt
+pulumi>=1.0.0
+pulumi-packet>=1.0.0
+pulumi-random>=1.0.0

ADD
packet-ts-webserver/Pulumi.yaml
+name: webserver-packet
+description: A simple server on Packet.
+runtime: nodejs
+

ADD
packet-ts-webserver/README.md
+[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)
+
+# Packet Webserver
+
+This example demonstrates creating a webserver in Packet.net
+
+# Running the Example
+
+After cloning this repo, `cd` into it and run these commands.
+
+1. Create a new stack, which is an isolated deployment target for this example:
+
+ ```bash
+ $ pulumi stack init
+ ```
+
+1. Install all of the dependencies for the application:
+
+ ```bash
+ $ npm install
+ ```
+
+1. Deploy everything with the `pulumi up` command. This provisions the webserver:
+
+ ```bash
+ $ pulumi up
+ ```
+
+1. After a couple minutes, your webserver will be ready.
+
+ ```bash
+ $ pulumi up
+ ...
+
+ Outputs:
+ + ip : "147.75.65.213"
+ + name: "new-vervet"
+ ```
+
+1. Once you are done, you can destroy all of the resources, and the stack:
+
+ ```bash
+ $ pulumi destroy
+ $ pulumi stack rm
+ ```

ADD
packet-ts-webserver/index.ts
+// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
+
+import * as packet from "@pulumi/packet";
+import * as random from "@pulumi/random";
+
+const randomHostName = new random.RandomPet("hostname");
+const randomProjectName = new random.RandomPet("project-name");
+
+const project = new packet.Project("project", {
+ name: randomProjectName.id,
+});
+
+const vm = new packet.Device("vm", {
+ facilities: [packet.Facilities.EWR1],
+ billingCycle: packet.BillingCycles.Hourly,
+ hostname: randomHostName.id,
+ operatingSystem: packet.OperatingSystems.CoreOSStable,
+ plan: packet.Plans.T1SmallX86,
+ projectId: project.id,
+ ipAddressTypes: [packet.IpAddressTypes.PublicIPv4, packet.IpAddressTypes.PrivateIPv4, packet.IpAddressTypes.PublicIPv6],
+});
+
+export const ip = vm.accessPublicIpv4;
+export const name = vm.hostname;

ADD
packet-ts-webserver/package.json
+{
+ "name": "packet-ts-webserver",
+ "version": "0.1.0",
+ "devDependencies": {
+ "@types/node": "^8.0.0"
+ },
+ "dependencies": {
+ "@pulumi/packet": "latest",
+ "@pulumi/random": "latest"
+ },
+ "license": "Apache-2.0"
+}

ADD
packet-ts-webserver/tsconfig.json
+{
+ "compilerOptions": {
+ "outDir": "bin",
+ "target": "es6",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "sourceMap": true,
+ "stripInternal": true,
+ "experimentalDecorators": true,
+ "pretty": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noImplicitReturns": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictNullChecks": true
+ },
+ "files": [
+ "index.ts"
+ ]
+}
+

Adding Packet example for Py and Ts (#447)