UNCLASSIFIED

Skip to content
Snippets Groups Projects
Commit c9c7b4c9 authored by kmc-home's avatar kmc-home
Browse files

update terraform

parent 4f17bc5a
No related merge requests found
......@@ -9,12 +9,43 @@ terraform {
provider "openstack" {
# Configuration options
auth_url = "https://vta.cybbh.space:5000"
}
data "openstack_networking_network_v2" "this" {
name = "public"
# data "openstack_networking_network_v2" "this" {
# name = "public"
# }
# resource "openstack_networking_router_v2" "external_router" {
# name = "router_${var.prefix}"
# external_network_id = data.openstack_networking_network_v2.this.id
# }
variable "sec_group" {
type = object(
{
name = string
description = string
rules = list(object(
{
description = optional(string)
ethertype = string
direction = string
protocol = optional(string)
port_range_min = optional(number)
port_range_max = optional(number)
remote_ip_prefix = optional(string)
}))
}
)
}
resource "openstack_networking_router_v2" "external_router" {
name = "router_${var.prefix}"
external_network_id = data.openstack_networking_network_v2.this.id
# -------------------------------------------------------------------------- #
# RESOURCES----------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# This is a provider defined resource that creates a Security Group
resource "openstack_networking_secgroup_v2" "secgroup" {
name = var.sec_group.name
description = var.sec_group.description
}
\ No newline at end of file
......@@ -19,34 +19,25 @@ Core concepts:
## Hands-on with Terraform Commands I
### terraform init
Initializes a Terraform working directory, downloading providers and modules.
Exercise 1: Initialize a project
```sh
# Create basic configuration
cat << EOF > main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
EOF
cd /root/woac-infra-demo/ranges/terraform/terraform-test
terraform init
```
### terraform plan
Shows execution plan for infrastructure changes.
Exercise 2: Create and review a plan
```sh
terraform plan
```
`terraform plan`
### terraform apply
Applies the changes required to reach desired state.
Exercise 3: Apply configuration
......@@ -56,6 +47,7 @@ terraform apply -auto-approve # Skip approval prompt
```
### terraform destroy
Removes all resources managed by the configuration.
Exercise 4: Clean up resources
......@@ -72,6 +64,7 @@ terraform destroy
## Terraform Configuration Basics
### Provider Configuration
```hcl
provider "aws" {
region = "us-west-2"
......@@ -79,6 +72,7 @@ provider "aws" {
```
### Resource Blocks
```hcl
resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0"
......@@ -91,6 +85,7 @@ resource "aws_instance" "example" {
```
### Variables
```hcl
# variables.tf
variable "instance_type" {
......@@ -106,6 +101,7 @@ resource "aws_instance" "example" {
```
### Outputs
```hcl
output "instance_ip" {
value = aws_instance.example.public_ip
......@@ -198,6 +194,7 @@ module "web_server" {
### Basic Infrastructure
Create a configuration that:
- Provisions a VPC
- Creates public and private subnets
......@@ -206,6 +203,7 @@ Create a configuration that:
### Module Development
Create a reusable module for:
- Network infrastructure
- Standard security groups
......@@ -214,6 +212,7 @@ Create a reusable module for:
### Multi-Environment Setup
Implement:
- Workspace-based environments
- Environment-specific variables
......@@ -222,6 +221,7 @@ Implement:
### Remote State
Configure:
- Remote state storage
- State locking
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment