在AWS第1部分中使用Terraform自动缩放组:基本步骤
因此,您想使用Terraform在AWS上创建一个自动缩放组。 以下是达到此目的的最少步骤。
在编写实际代码之前,应指定aws terraform提供程序以及provider.tf文件上的区域。
provider "aws" { version = "~> 2.0" region = "eu-west-1" } terraform { required_version = "~>0.12.0" }
然后我们将
第一步是在variables.tf文件上定义一些变量。
variable "vpc_id" { type = string default = "your-vpc-id" } variable "launch_configuration_name" { type = string default = "launch_configuration_name" } variable "auto_scalling_group_name" { type = string default = "auto_scalling_group_name" } variable "image_id" { type = string default = "image-id-based-on-the-region" } variable "instance_type" { type = "string" default = "t2.micro" }
然后,我们将在autoscalling_group.tf文件上具有自动缩放组配置。
data "aws_subnet_ids" "subnets" { vpc_id = var.vpc_id } data "aws_subnet" "subnet_values" { for_each = data.aws_subnet_ids.subnets.ids id = each.value } resource "aws_launch_configuration" "launch-configuration" { name = var.launch_configuration_name image_id = var.image_id instance_type = var.instance_type } resource "aws_autoscaling_group" "autoscalling_group_config" { name = var.auto_scalling_group_name max_size = 3 min_size = 2 health_check_grace_period = 300 health_check_type = "EC2" desired_capacity = 3 force_delete = true vpc_zone_identifier = [ for s in data.aws_subnet.subnet_values: s. id ] launch_configuration = aws_launch_configuration.launch-configuration.name lifecycle { create_before_destroy = true } }
让我们分解一下。 需要vpc ID才能识别自动伸缩组使用的子网。 因此,值vpc_zone_identifier将从定义的vpc派生子网。
然后,您必须创建启动配置。 启动配置应指定基于您所在地区和实例类型的映像ID。
要执行此操作,前提是您拥有aws凭证,因此必须进行初始化,然后应用
> terraform init > terraform apply
翻译自: https://www.javacodegeeks.com/2020/01/autoscaling-groups-with-terraform-on-aws-part-1-basic-steps.html
在AWS第1部分中使用Terraform自动缩放组:基本步骤相关推荐
- aws terraform_在AWS第1部分中使用Terraform自动缩放组:基本步骤
aws terraform 因此,您想使用Terraform在AWS上创建一个自动缩放组. 以下是达到此目的的最少步骤. 在编写实际代码之前,应指定aws terraform提供程序以及provide ...
- C#中窗体的自动缩放(Winform)
1.使用ReSize事件 public partial class Form1 : Form{private float x;private float y;public Form1(){
- aws集群重启_使用自动伸缩组在AWS中运行安全数据库集群
aws集群重启 当您必须在AWS上运行可扩展应用程序时,您的数据库也必须是可扩展的. 扩展无状态应用程序层更容易,在无状态应用程序层中,每个节点几乎都是一次性的-即使3节点集群中的一个节点发生故障,您 ...
- 使用自动伸缩组在AWS中运行安全数据库集群
当您必须在AWS上运行可伸缩应用程序时,您的数据库也必须可伸缩. 扩展无状态应用程序层更容易,在无状态应用程序层中,每个节点大部分都是可使用的-即使3节点集群中的一个节点发生故障,您也可以启动另一个节 ...
- aws 性能_AWS上的应用程序自动扩展–选项和对性能的影响
aws 性能 至关重要的是扩展软件应用程序,以避免由于网站的客户群或需要处理大型数据集的应用程序等导致的工作负载增加而导致性能瓶颈的情况.云服务提供商通常是访问其他应用程序的最佳方法随需应变的资源,可 ...
- 使用AWS Lambda在Go中构建RESTful API
在本文中,我们将学习使用AWS Lambda在Go中设计,构建和部署RESTful API. 在开始之前,让我给您简要介绍一下AWS Lambda. 什么是AWS Lambda? AWS Lambda ...
- aws ec2时间_AWS中自动化的三大领域,以避免支付过多的云账单
AWS是全球最常用的云服务之一. Gartner Magic Quadrant将AWS评为最大的IaaS提供商.每个可能的域都由企业使用AWS服务. 全球约有 1,000,000家公司正在使用AWS作 ...
- 在AWS RDS SQL Server中恢复数据
This article explores the process to recover data in AWS RDS SQL Server and its recent enhancements. ...
- aws rds监控慢sql_在AWS RDS SQL Server中实施SSL连接
aws rds监控慢sql This article explores a method to enforce SSL for all connections in AWS RDS SQL Serve ...
最新文章
- 【activeMQ】一、入门
- Android中的音乐播放
- 从思维导图学习操作系统(二)
- OpenGL perpixelgloss逐像素光泽度的实例
- C++常用字符串分割方法
- 数据分析师就是个 SQL boy?
- 内含福利 | 我们“偷”来了一座航站楼。9.21, HAY!18等你来候机!
- python 判断是字母的多种方法
- ID与Class的区别(#与。的区别)CSS
- 摄氏度和开氏度的换算_开尔文与摄氏度的换算关系
- 程序猿12个人艰不拆的真相
- ACM-ICPC 2018 沈阳赛区网络预赛 F题 Fantastic Graph
- 计算机网络的应用阶层,计算机网络应用专业人才培养方案.doc
- pythonopencv人脸识别考勤_Python+Opencv+Tkinter指纹识别与人脸识别的门禁兼考勤(一)...
- Angular4 自制华容道拼图(可以升级难度、关卡、更换图片)
- python花瓣图_【爬虫】花瓣图片爬虫,Python图片采集下载源码
- POJ 3009 Curling 2.0 {深度优先搜索}
- 2021年全球与中国再生鼓风机行业市场规模及发展前景分析
- 用python算卦——银钱演算法
- linux ubunt16.04 x86_64 安装最新稳定版wine,解决:Unable to locate package winehq-stable