Skip to content

Commit

Permalink
Adding Equinix Metal examples equivalent to Packet.net to help with p…
Browse files Browse the repository at this point in the history
…rovider deprecation (pulumi#907)
  • Loading branch information
stack72 authored Feb 10, 2021
1 parent dec20c0 commit 327afe3
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ jobs:
- Aws
- Azure
- Gcp
- EquinixMetal
- Packet
- Cloud
dotnet-version:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/run-tests-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ jobs:
- Azure
- Gcp
- Packet
- EquinixMetal
- Cloud
dotnet-version:
- 3.1.301
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/smoke-test-cli-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ jobs:
- Azure
- Gcp
- Packet
- EquinixMetal
- Cloud
dotnet-version:
- 3.1.301
Expand Down
1 change: 1 addition & 0 deletions equinix-metal-py-webserver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
3 changes: 3 additions & 0 deletions equinix-metal-py-webserver/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: equinix-metal-py-webserver
description: A simple server on Equinix Metal.
runtime: python
51 changes: 51 additions & 0 deletions equinix-metal-py-webserver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)

# Equinix Metal Webserver

This example demonstrates creating a webserver in Equinix Metal 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:

1. Create a Python virtualenv, activate it, and install dependencies:

This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.

```bash
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```

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
```
27 changes: 27 additions & 0 deletions equinix-metal-py-webserver/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pulumi_equinix_metal as metal
import pulumi_random as random
from pulumi import export

random_host_name = random.RandomPet("hostname")

project = metal.get_project(
name="ci-project"
)

vm = metal.Device(
"vm",
billing_cycle="hourly",
facilities=["ewr1"],
hostname=random_host_name.id,
operating_system="coreos_stable",
plan="baremetal_0",
project_id=project.id,
ip_addresses=[{
"type": "public_ipv4",
}, {
"type": "private_ipv4",
}]
)

export('ip', vm.access_public_ipv4)
export('name', vm.hostname)
3 changes: 3 additions & 0 deletions equinix-metal-py-webserver/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pulumi>=2.0.0,<3.0.0
pulumi-equinix-metal>=1.0.0,<2.0.0
pulumi-random>=2.0.0,<3.0.0
4 changes: 4 additions & 0 deletions equinix-metal-ts-webserver/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: webserver-equinix-metal
description: A simple server on Equinix Metal.
runtime: nodejs

45 changes: 45 additions & 0 deletions equinix-metal-ts-webserver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)

# Equinix Metal Webserver

This example demonstrates creating a webserver in Equinix Metal

# 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
```
26 changes: 26 additions & 0 deletions equinix-metal-ts-webserver/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as metal from "@pulumi/equinix-metal";
import * as random from "@pulumi/random";

const randomHostName = new random.RandomPet("hostname");

const project = metal.getProject({name: "ci-project"});

const vm = new metal.Device("vm", {
facilities: [metal.Facility.EWR1],
billingCycle: metal.BillingCycle.Hourly,
hostname: randomHostName.id,
operatingSystem: metal.OperatingSystem.CoreOSStable,
plan: metal.Plan.T1SmallX86,
projectId: project.then(p => p.id),
ipAddresses: [{
type: "public_ipv4",
},
{
type: "private_ipv4",
}],
});

export const ip = vm.accessPublicIpv4;
export const name = vm.hostname;
12 changes: 12 additions & 0 deletions equinix-metal-ts-webserver/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "equinix-metal-ts-webserver",
"version": "0.1.0",
"devDependencies": {
"@types/node": "^8.0.0"
},
"dependencies": {
"@pulumi/equinix-metal": "^1.0.0",
"@pulumi/random": "latest"
},
"license": "Apache-2.0"
}
21 changes: 21 additions & 0 deletions equinix-metal-ts-webserver/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"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"
]
}

20 changes: 19 additions & 1 deletion misc/test/packet_test.go → misc/test/equinix_metal_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build packet all
// +build equinix_metal all

package test

Expand All @@ -18,6 +18,15 @@ func TestAccPacketPyWebserver(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestAccEquinixMetalPyWebserver(t *testing.T) {
test := getBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "..", "..", "equinix-metal-py-webserver"),
})

integration.ProgramTest(t, &test)
}

func TestAccPacketTsWebserver(t *testing.T) {
test := getBaseOptions(t).
With(integration.ProgramTestOptions{
Expand All @@ -26,3 +35,12 @@ func TestAccPacketTsWebserver(t *testing.T) {

integration.ProgramTest(t, &test)
}

func TestAccEquinixMetalTsWebserver(t *testing.T) {
test := getBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "..", "..", "equinix-metal-ts-webserver"),
})

integration.ProgramTest(t, &test)
}

0 comments on commit 327afe3

Please sign in to comment.