Skip to content

Commit 4228300

Browse files
committed
Comment and clean up example
1 parent 84655eb commit 4228300

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

examples/ec2_dir_copy/index.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { hashElement } from "folder-hash";
88
import { size } from "./size";
99

1010
export = async () => {
11+
// Get a key pair to connect to the EC2 instance. If the name of an existing key pair is
12+
// provided, use it, otherwise create one. We get the private key from config, or default to
13+
// the default id_rsa SSH key.
1114
const config = new pulumi.Config();
1215
const keyName = config.get("keyName") ??
1316
new aws.ec2.KeyPair("key", { publicKey: config.require("publicKey") }).keyName;
@@ -16,14 +19,15 @@ export = async () => {
1619
Buffer.from(privateKeyBase64, 'base64').toString('ascii') :
1720
fs.readFileSync(path.join(os.homedir(), ".ssh", "id_rsa")).toString("utf8");
1821

22+
// Create a security group that allows SSH traffic.
1923
const secgrp = new aws.ec2.SecurityGroup("secgrp", {
2024
description: "Foo",
2125
ingress: [
2226
{ protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
23-
{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
2427
],
2528
});
2629

30+
// Get the latest Amazon Linux AMI (image) for the region we're using.
2731
const ami = aws.ec2.getAmiOutput({
2832
owners: ["amazon"],
2933
mostRecent: true,
@@ -33,6 +37,7 @@ export = async () => {
3337
}],
3438
});
3539

40+
// Create the EC2 instance we will copy files to.
3641
const server = new aws.ec2.Instance("server", {
3742
instanceType: size,
3843
ami: ami.id,
@@ -42,18 +47,14 @@ export = async () => {
4247
replaceOnChanges: ["instanceType"],
4348
});
4449

50+
// The configuration of our SSH connection to the instance.
4551
const connection: types.input.remote.ConnectionArgs = {
4652
host: server.publicIp,
4753
user: "ec2-user",
4854
privateKey: privateKey,
4955
};
5056

51-
const connectionNoDialRetry: types.input.remote.ConnectionArgs = {
52-
...connection,
53-
dialErrorLimit: 1,
54-
};
55-
56-
// We poll the server until it responds.
57+
// Poll the server until it responds.
5758
//
5859
// Because other commands depend on this command, other commands are guaranteed
5960
// to hit an already booted server.

examples/ec2_dir_copy/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@pulumi/aws": "^6.0.0",
99
"@pulumi/awsx": "^2.0.2",
10-
"@pulumi/command": "^0.10",
10+
"@pulumi/command": "^0.11",
1111
"@pulumi/pulumi": "^3.113.0",
1212
"@types/folder-hash": "^4.0.4",
1313
"folder-hash": "^4.0.4",

0 commit comments

Comments
 (0)