Debian Codegraph @

examples/terraform/consul.jsonnet

raw
1 // These can split into separate files, come from environment variables / commandline etc., as
2 // desired.
3 local aws_region = 'us-east-1';
4
5 // Ubuntu Precise 12.04 LTS (x64)
6 local aws_amis = {
7 'eu-west-1': 'ami-b1cf19c6',
8 'us-east-1': 'ami-de7ab6b6',
9 'us-west-1': 'ami-3f75767a',
10 'us-west-2': 'ami-21f78e11',
11 };
12
13 {
14 provider: {
15 // Setup the Consul provisioner to use the demo cluster
16 consul: {
17 address: 'demo.consul.io:80',
18 datacenter: 'nyc1',
19 scheme: 'http',
20 },
21 // Setup an AWS provider
22 aws: {
23 region: aws_region,
24 access_key: 'XXX',
25 secret_key: 'YYY',
26 },
27 },
28
29 resource: {
30 aws_instance: {
31
32 // Object comprehension syntax (similar to Python)
33 test: {
34 // i is a scoped variable here
35 instance_type: '${consul_keys.input.var.size}',
36 ami: aws_amis[aws_region],
37 },
38 },
39
40 consul_keys: {
41 // Setup a key in Consul to provide inputs
42 input: {
43 key: {
44 name: 'size',
45 path: 'tf_test/size',
46 default: 'm1.small',
47 },
48 },
49
50 // Setup a key in Consul to store the instance id and
51 // the DNS name of the instance
52 test: {
53 key: [
54 {
55 name: 'id',
56 path: 'tf_test/id',
57 value: '${aws_instance.test.id}',
58 delete: true,
59 },
60 {
61 name: 'address',
62 path: 'tf_test/public_dns',
63 value: '${aws_instance.test.public_dns}',
64 delete: true,
65 },
66 ],
67 },
68 },
69 },
70 }