Deploy infrastructure
To finish we just need to deploy the new configuration on the public cloud. To do this initialize Terraform with the command bellow the project folder (near main.tf)
terraform init
Initializing the backend...
Initializing provider plugins...
- Finding terraform-provider-openstack/openstack versions matching "1.44.0"...
- Installing terraform-provider-openstack/openstack v1.44.0...
- Installed terraform-provider-openstack/openstack v1.44.0 (self-signed, key ID 4F80527A391BEFD2)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
terraform validate
Success! The configuration is valid.
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# openstack_compute_instance_v2.web-server will be created
+ resource "openstack_compute_instance_v2" "web-server" {
+ access_ip_v4 = (known after apply)
+ access_ip_v6 = (known after apply)
+ all_metadata = (known after apply)
+ all_tags = (known after apply)
+ availability_zone = (known after apply)
+ flavor_id = (known after apply)
+ flavor_name = "a1-ram2-disk80-perf1"
+ force_delete = false
+ id = (known after apply)
+ image_id = "9be06f9c-a8e8-4f33-b41e-d35f29667fcb"
+ image_name = (known after apply)
+ key_pair = "web-keypair"
+ metadata = {
+ "application" = "web-app"
}
+ name = "web-server"
+ power_state = "active"
+ region = (known after apply)
+ security_groups = [
+ "sg-web-front",
]
+ stop_before_destroy = false
+ network {
+ access_network = false
+ fixed_ip_v4 = (known after apply)
+ fixed_ip_v6 = (known after apply)
+ floating_ip = (known after apply)
+ mac = (known after apply)
+ name = "ext-net1"
+ port = (known after apply)
+ uuid = (known after apply)
}
}
# openstack_compute_keypair_v2.web-keypair will be created
+ resource "openstack_compute_keypair_v2" "web-keypair" {
+ fingerprint = (known after apply)
+ id = (known after apply)
+ name = "web-keypair"
+ private_key = (known after apply)
+ public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1MvU9Df0n2UBaII35aFuM9pQaQd1NEJOrB6xLNs43Ca6OoL7+7mv8C2pTr4DvqNhGoCEZuZULo8ArBixZtqFYgJHZY0a5FtjqO8azyFycUcNK7QSM265tiN6CJwyepcw0P6Ucsvjeu5wLwyylUInYH7qzYKV2F85vMIkWA+r1a5xLA8M/DDw/jwIGnuU9GxDMmB/hIbj4A5tOpppyPhQxJX8BJlyiXF2PDzVTKjVEB3TWcnHRAUqFu/0V2Gft5ZCqXwiNpboms6AVJYKPbNWmVf+JrEjVcaOEwZnzyB0tcpeIbW/bwIEJmygHLttHDsfsLZN1El/nO/SZFOZ8/K02QE8h4hCjjHmffK2CEqToGaMhwnCZWGrQq+Q1tQnISZ6uNYLotklRkHh8889knIrLGL2x0q811pbFE7pMe3TTdcs+N+ZPdmMLkJhHai91rwfVtYsKFaRomp8RNMDKOic3U2wQJ4qAf2cqs084ird/tMsCYedZfx5rAqT3TyDB8JDNEVd1ie+9m5K2xQqVVOYUCtbemF6g99F6AqfsYAGpLC4BGGk2mbZCg3baDfJh8n2e6wgM8+eb9kQP5ExGDow7NahSlP+uuAgncCRE8AEpSQPrfpiW207IGI2MLo2iFCjuhwRSdhYzy3mYlUIJvectuO9wMcLsMGBrYuaomPiyCw== cardno:000605009830"
+ region = (known after apply)
}
# openstack_compute_secgroup_v2.sg-web-front will be created
+ resource "openstack_compute_secgroup_v2" "sg-web-front" {
+ description = "Security group for web front instances"
+ id = (known after apply)
+ name = "sg-web-front"
+ region = (known after apply)
+ rule {
+ cidr = "0.0.0.0/0"
+ from_port = 22
+ id = (known after apply)
+ ip_protocol = "tcp"
+ self = false
+ to_port = 22
}
+ rule {
+ cidr = "0.0.0.0/0"
+ from_port = 443
+ id = (known after apply)
+ ip_protocol = "tcp"
+ self = false
+ to_port = 443
}
+ rule {
+ cidr = "0.0.0.0/0"
+ from_port = 80
+ id = (known after apply)
+ ip_protocol = "tcp"
+ self = false
+ to_port = 80
}
}
Plan: 3 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
During the deployment you should obtain a result like this:
openstack_compute_keypair_v2.web-keypair: Creating...
openstack_compute_secgroup_v2.sg-web-front: Creating...
openstack_compute_instance_v2.web-server: Creating...
openstack_compute_keypair_v2.web-keypair: Creation complete after 0s [id=web-keypair]
openstack_compute_secgroup_v2.sg-web-front: Creation complete after 1s [id=fe0eb17d-9f2d-4117-a9eb-730951d68108]
openstack_compute_instance_v2.web-server: Still creating... [10s elapsed]
openstack_compute_instance_v2.web-server: Creation complete after 13s [id=5babb72a-8ccd-4f41-bdff-2476c3903e66]
Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
Success
Your resources are now successfully deployed with Terrafom on Infomaniak Public Cloud.