@@ -4,7 +4,7 @@ Creates a standalone Docker host on EC2, optionally attaching an external EBS vo
4
4
5
5
This is convenient for quickly setting up non-production-critical Docker workloads. If you need something fancier, consider e.g. ECS, EKS or Fargate.
6
6
7
- ## Example 1
7
+ ## Example 1: Running a docker container
8
8
9
9
Assuming you have the [ AWS provider] ( https://www.terraform.io/docs/providers/aws/index.html ) set up:
10
10
@@ -32,7 +32,7 @@ $ DOCKER_HOST=localhost:2377 docker run -d -p 80:80 nginx
32
32
33
33
Visit the IP address of your host in a browser to make sure it works.
34
34
35
- ## Example 2
35
+ ## Example 2: Using a persistent data volume
36
36
37
37
Assuming you have the [ AWS provider] ( https://www.terraform.io/docs/providers/aws/index.html ) set up:
38
38
@@ -85,3 +85,32 @@ tmpfs 99M 0 99M 0% /run/user/1000
85
85
```
86
86
87
87
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