Skip to content

Commit 4a5a54e

Browse files
committed
Update docs for aws_ec2_ebs_docker_host.
1 parent 522bc2a commit 4a5a54e

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

aws_ec2_ebs_docker_host/README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Creates a standalone Docker host on EC2, optionally attaching an external EBS vo
44

55
This is convenient for quickly setting up non-production-critical Docker workloads. If you need something fancier, consider e.g. ECS, EKS or Fargate.
66

7-
## Example 1
7+
## Example 1: Running a docker container
88

99
Assuming you have the [AWS provider](https://www.terraform.io/docs/providers/aws/index.html) set up:
1010

@@ -32,7 +32,7 @@ $ DOCKER_HOST=localhost:2377 docker run -d -p 80:80 nginx
3232

3333
Visit the IP address of your host in a browser to make sure it works.
3434

35-
## Example 2
35+
## Example 2: Using a persistent data volume
3636

3737
Assuming you have the [AWS provider](https://www.terraform.io/docs/providers/aws/index.html) set up:
3838

@@ -85,3 +85,32 @@ tmpfs 99M 0 99M 0% /run/user/1000
8585
```
8686

8787
That is, you can see the 25 GB data volume mounted at `/data`.
88+
89+
## Example 3: Running additional provisioners
90+
91+
Assuming you have the [AWS provider](https://www.terraform.io/docs/providers/aws/index.html) set up:
92+
93+
```tf
94+
module "my_host" {
95+
source = "./aws_ec2_ebs_docker_host"
96+
97+
hostname = "my-docker-host"
98+
ssh_private_key_path = "~/.ssh/id_rsa"
99+
ssh_public_key_path = "~/.ssh/id_rsa.pub"
100+
}
101+
102+
resource "null_resource" "provisioners" {
103+
depends_on = ["module.my_host"] # wait until other provisioners within the module have finished
104+
105+
connection {
106+
host = "${module.my_host.public_ip}"
107+
user = "${module.my_host.ssh_username}"
108+
private_key = "${module.my_host.ssh_private_key}"
109+
agent = false
110+
}
111+
112+
provisioner "remote-exec" {
113+
inline = ["echo HELLO WORLD"]
114+
}
115+
}
116+
```

0 commit comments

Comments
 (0)