forked from uyuni-project/sumaform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf.aws-create-mirror-snapshot.example
104 lines (91 loc) · 2.96 KB
/
main.tf.aws-create-mirror-snapshot.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// This template can be used to create a mirror hosts data snapshot.
// To do so, copy this template to main.tf, fill in your SCC and AWS
// credentials and the regions.
// Create a mirror instance using 'terraform apply', and if successful,
// follow the instruction in backend_modules/aws/README_ADVANCED.md
// If you want to base the data disk on an existing snapshot, either set
// data_volume_snapshot_id to the ID of the snapshot to use, or set it
// to "${data.aws_ebs_snapshot.data_disk_snapshot.id}" to look up the
// latest snapshot.
//
// For more information see backend_modules/aws/README_ADVANCED.md
locals {
cc_username = "" // SCC or NCC username
cc_password = "" // SCC password
key_name = "" // SSH key name
key_file = "" // SSH key file
name_prefix = "mirrorsnap-"
region = "eu-west-2"
availability_zone = "${local.region}a"
product_version = "5.0-released"
ssh_allowed_ips = [""] // add your IP address in here
}
provider "aws" {
region = local.region
access_key = ...
secret_key = ...
}
module "base" {
source = "./modules/base"
cc_username = local.cc_username
cc_password = local.cc_password
name_prefix = local.name_prefix
product_version = local.product_version
provider_settings = {
availability_zone = local.availability_zone
region = local.region
ssh_allowed_ips = local.ssh_allowed_ips
key_name = local.key_name
key_file = local.key_file
}
}
// uncomment next module to use existing snapshot as starting point
//data "aws_ebs_snapshot" "data_disk_snapshot" {
// most_recent = true
//
// filter {
// name = "tag:Name"
// values = ["mirror-data-volume-snapshot"]
// }
//}
module "mirror" {
source = "./modules/mirror"
base_configuration = module.base.configuration
provider_settings = {
public_instance = true
}
volume_provider_settings = {
// uncomment next line to use existing snapshot as starting point
// volume_snapshot_id = data.aws_ebs_snapshot.data_disk_snapshot.id
}
}
// uncomment next modules if you want to create a snapshot of the existing data disk
//data "aws_ebs_volume" "data_disk_id" {
// most_recent = true
//
// filter {
// name = "tag:Name"
// values = ["${module.base.configuration["name_prefix"]}mirror-data-volume"]
// }
//}
//
// Attention: if you run terraform destroy, you will remove the snapshot.
// One should remove snapshot state first. For more information see backend_modules/aws/README_ADVANCED.md
//resource "aws_ebs_snapshot" "mirror_data_snapshot" {
// volume_id = data.aws_ebs_volume.data_disk_id.id
// timeouts {
// create = "60m"
// delete = "60m"
// }
// tags = {
// Name = "mirror-data-volume-snapshot"
// }
//}
output "configuration" {
value = {
base = module.base.configuration
mirror = module.mirror.configuration
region = local.region
//snapshot_name = data.aws_ebs_snapshot.data_disk_snapshot
}
}