1

GitHub - Percona-Lab/terraform-provider-percona: Terraform modules to deploy Per...

 1 year ago
source link: https://github.com/Percona-Lab/terraform-provider-percona
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Percona Terraform Provider

DISCLAIMER

This is an experimental project, use on your own risk. This project is not covered by Percona Support

Requirements

  • Terraform 1.1.2
  • Go 1.18.x (to build the provider plugin)
  • AWS 1 or 2 version

How to run on AWS

  1. Clone repo
  2. Configure AWS CLI - tutorial
  3. Switch to project directory
  4. Execute in console make all or go through Makefile(in the root of project) manually
  5. When cluster is set up, connect to one of the PXC instances
  6. Login to mysql with command sudo mysql -uroot -p and enter password password
  7. Check cluster status show status like 'wsrep%';
  8. Connect to one of the Percona Server replica
  9. Check replication status using SHOW SLAVE STATUS\G on replica

How to run on Google Cloud Platform

  1. Create service account in Google Cloud Console and create key for it (for more info, visit https://cloud.google.com/docs/authentication/getting-started)
  2. Export GOOGLE_APPLICATION_CREDENTIALS environment variable to point to the file with credentials (e.g. export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json)
  3. Execute make all

Configuration

File main.tf

# AWS provider configuration
provider "percona" {
  region                   = "eu-north-1"               # required
  profile                  = "default"                  # optional
  cloud                    = "aws"                      # required, supported values: "aws", "gcp"
  ignore_errors_on_destroy = true                       # optional, default: false
}

# GCP provider configuration
#provider "percona" {
#  region                   = "europe-west1"
#  zone                     = "europe-west1-c"
#  project                  = "project-name"
#  cloud                    = "gcp"
#  ignore_errors_on_destroy = false
#}

resource "percona_ps" "ps" {
  instance_type            = "t3.micro"         # required
  key_pair_name            = "sshKey1"          # required
  password                 = "password"         # optional, default: "password"
  replica_password         = "replicaPassword"  # optional, default: "replicaPassword"
  cluster_size             = 2                  # optional, default: 3
  path_to_key_pair_storage = "/tmp/"            # optional, default: "."
  volume_type              = "gp2"              # optional, default: "gp2" for AWS, "pd-balanced" for GCP
  volume_size              = 20                 # optional, default: 20
  volume_iops              = 4000               # optional
  config_file_path         = "./config.cnf"     # optional, saves config file to /etc/mysql/mysql.conf.d/custom.cnf
  version                  = "8.0.28"           # optional, installs last version if not specified
  myrocks_install          = true               # optional, default: false
  vpc_name                 = "percona_vpc_1"    # optional
}

resource "percona_pxc" "pxc" {
  instance_type            = "t3.micro"         # required
  key_pair_name            = "sshKey2"          # required
  password                 = "password"	        # optional, default: "password"
  cluster_size             = 2      	        # optional, default: 3
  path_to_key_pair_storage = "/tmp/"            # optional, default: "."
  volume_type              = "gp2"              # optional, default: "gp2" for AWS, "pd-balanced" for GCP
  volume_size              = 20                 # optional, default: 20
  volume_iops              = 4000               # optional
  config_file_path         = "./config.cnf"     # optional, saves config file to /etc/mysql/mysql.conf.d/custom.cnf
  version                  = "8.0.28"           # optional, installs last version if not specified
  vpc_name                 = "percona_vpc_1"    # optional
}

File version.tf

terraform {
  required_providers {
    percona = {
      version = "~> 0.9.0"
      source  = "terraform-percona.com/terraform-percona/percona"
    }
  }
}

Required permissions

For AWS

Instance types, in some regions some may be available and in others they may not.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK