File tree Expand file tree Collapse file tree 3 files changed +100
-0
lines changed
quickstarts/RDS/201-use-case-manage-rds-sql-audit-feature Expand file tree Collapse file tree 3 files changed +100
-0
lines changed Original file line number Diff line number Diff line change 1+ ## Introduction
2+
3+ <!-- DOCS_DESCRIPTION_CN -->
4+ 本示例用于在阿里云上开启和关闭RDS SQL审计。
5+ 详情可查看[ 通过 Terraform 开启和关闭RDS PostgreSQL的SQL审计] ( http://help.aliyun.com/document_detail/456033.htm ) 。
6+ <!-- DOCS_DESCRIPTION_CN -->
7+
8+ <!-- DOCS_DESCRIPTION_EN -->
9+ This example is used to enable and disable the SQL Audit feature for an RDS instance on Alibaba Cloud.
10+ More details in [ Use the RDS SQL Audit feature] ( http://help.aliyun.com/document_detail/456033.htm ) .
11+ <!-- DOCS_DESCRIPTION_EN -->
12+
13+ <!-- BEGIN_TF_DOCS -->
14+ ## Providers
15+
16+ | Name | Version |
17+ | ------| ---------|
18+ | <a name =" provider_alicloud " ></a > [ alicloud] ( #provider\_ alicloud ) | n/a |
19+
20+ ## Modules
21+
22+ No modules.
23+
24+ ## Resources
25+
26+ | Name | Type |
27+ | ------| ------|
28+ | [ alicloud_db_instance.instance] ( https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/db_instance ) | resource |
29+ | [ alicloud_vpc.main] ( https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vpc ) | resource |
30+ | [ alicloud_vswitch.main] ( https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vswitch ) | resource |
31+
32+ ## Inputs
33+
34+ | Name | Description | Type | Default | Required |
35+ | ------| -------------| ------| ---------| :--------:|
36+ | <a name =" input_instance_type " ></a > [ instance\_ type] ( #input\_ instance\_ type ) | n/a | ` string ` | ` "pg.n2.2c.2m" ` | no |
37+ | <a name =" input_region " ></a > [ region] ( #input\_ region ) | n/a | ` string ` | ` "cn-shenzhen" ` | no |
38+ | <a name =" input_target_minor_version " ></a > [ target\_ minor\_ version] ( #input\_ target\_ minor\_ version ) | n/a | ` string ` | ` "rds_postgres_1300_20240830" ` | no |
39+ | <a name =" input_zone_id " ></a > [ zone\_ id] ( #input\_ zone\_ id ) | n/a | ` string ` | ` "cn-shenzhen-c" ` | no |
40+ <!-- END_TF_DOCS -->
41+
42+ ## Documentation
43+ <!-- docs-link -->
44+
45+ The template is based on Aliyun document: [ Manage RDS SQL audit feature] ( http://help.aliyun.com/document_detail/456033.htm )
46+
47+ <!-- docs-link -->
Original file line number Diff line number Diff line change 1+ variable "region" {
2+ default = " cn-shenzhen"
3+ }
4+
5+ variable "zone_id" {
6+ default = " cn-shenzhen-c"
7+ }
8+
9+ variable "instance_type" {
10+ default = " pg.n2.2c.2m"
11+ }
12+
13+ variable "target_minor_version" {
14+ default = " rds_postgres_1300_20240830"
15+ }
16+
17+ provider "alicloud" {
18+ region = var. region
19+ }
20+
21+ # 创建VPC
22+ resource "alicloud_vpc" "main" {
23+ vpc_name = " alicloud"
24+ cidr_block = " 172.16.0.0/16"
25+ }
26+
27+ # 创建交换机
28+ resource "alicloud_vswitch" "main" {
29+ vpc_id = alicloud_vpc. main . id
30+ cidr_block = " 172.16.192.0/20"
31+ zone_id = var. zone_id
32+ }
33+
34+ # 创建RDS PostgreSQL实例
35+ resource "alicloud_db_instance" "instance" {
36+ engine = " PostgreSQL"
37+ engine_version = " 13.0"
38+ instance_type = var. instance_type
39+ instance_storage = " 30"
40+ instance_charge_type = " Postpaid"
41+ vswitch_id = alicloud_vswitch. main . id
42+ # 开启SQL审计(创建完RDS PostgreSQL实例后添加如下代码)
43+ sql_collector_status = " Enabled"
44+ # 关闭SQL审计
45+ # sql_collector_status = "Disabled"
46+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ alicloud = {
4+ source = " aliyun/alicloud"
5+ }
6+ }
7+ }
You can’t perform that action at this time.
0 commit comments