commit 8902c5c43a46110d9d2156f44a40024f1d477da1 Author: KF Date: Fri Jul 26 09:22:47 2024 +0800 NEW: initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b37dea --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ +.idea + +### Mac OS ### +.DS_Store + +### terraform ### +.terraform +terraform.tfstate +terraform.tfstate.backup +experimental diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe7fa09 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# alicloud terraform examples \ No newline at end of file diff --git a/alicloud-dev.iml b/alicloud-dev.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/alicloud-dev.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/examples/basic-networking/.terraform.lock.hcl b/examples/basic-networking/.terraform.lock.hcl new file mode 100644 index 0000000..aff0424 --- /dev/null +++ b/examples/basic-networking/.terraform.lock.hcl @@ -0,0 +1,20 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/alicloud" { + version = "1.227.1" + hashes = [ + "h1:V0JQAnqamfNKXhlZO7Ci5KyBLFBnHAej8DvFJ8PQpZc=", + "zh:15b5c4fe3bec5fb97606e7143a8cfd346529bcc9b51c0d0f29aac98d47bd4504", + "zh:3a8e666eed369e9b51a967f76126c6106f2594241709b7085d0f22d2cec1695b", + "zh:410b52b99bbb8dbc3fe8ac247dcd752e7418a359570e8f7d33d0002f73e1ba24", + "zh:6325cee8f418712933ef531084defe2f2a5f1571e483de4e2b8dd8c879b86166", + "zh:8b9213c763b019043293dd5b34c8fdf9c6267f130eadda3513cedcacda2bd168", + "zh:c2041fc4cda4475338ee55c27687d391f6363d8fb2b5301945a331639aea7cf5", + "zh:ccb1029e07c5c84a03d29f481a18efcfc2b590647361f2623a312114fe615a2f", + "zh:d55eaa08f5a06481ecbe44661bffc58b60f6d82c502ed4cf813d6849e5946eac", + "zh:eade88066e2ff112b616aca564d6e0b4d45a4cf3103d2cbf90f2c91c21cb357a", + "zh:f035cb6992d292928e087ddf4b0c6e232ed6b04e1bf1372e38e027d6648078f8", + "zh:fae90ca83ccf3ea074aa5a611a5d12388c75d4393b2bd9da408b3f37197fe9c3", + ] +} diff --git a/examples/basic-networking/main.tf b/examples/basic-networking/main.tf new file mode 100644 index 0000000..0189655 --- /dev/null +++ b/examples/basic-networking/main.tf @@ -0,0 +1,8 @@ +resource "alicloud_vpc" "vpc" { + vpc_name = var.vpc-name + description = var.vpc-description + cidr_block = var.vpc-cidr + is_default = true + enable_ipv6 = false + tags = local.tags +} \ No newline at end of file diff --git a/examples/basic-networking/outputs.tf b/examples/basic-networking/outputs.tf new file mode 100644 index 0000000..9f7b29a --- /dev/null +++ b/examples/basic-networking/outputs.tf @@ -0,0 +1,3 @@ +output "vpc-id" { + value = alicloud_vpc.vpc.id +} \ No newline at end of file diff --git a/examples/basic-networking/provider.tf b/examples/basic-networking/provider.tf new file mode 100644 index 0000000..ffa3e1e --- /dev/null +++ b/examples/basic-networking/provider.tf @@ -0,0 +1,12 @@ +/* Authentication +Use environment variables +$ export ALICLOUD_ACCESS_KEY="" +$ export ALICLOUD_SECRET_KEY="" +$ export ALICLOUD_REGION="cn-beijing" + +Or instance role +ecs_role_name = "terraform-provider-alicloud" + */ +provider "alicloud" { + region = "cn-hongkong" +} \ No newline at end of file diff --git a/examples/basic-networking/tags.tf b/examples/basic-networking/tags.tf new file mode 100644 index 0000000..6a89f68 --- /dev/null +++ b/examples/basic-networking/tags.tf @@ -0,0 +1,6 @@ +locals { + tags = { + Owner = "xpk" + TerraformDir = join("/", reverse(slice(reverse(split("/", path.cwd)), 0, 2))) + } +} \ No newline at end of file diff --git a/examples/basic-networking/terraform.tfvars b/examples/basic-networking/terraform.tfvars new file mode 100644 index 0000000..dff5c9f --- /dev/null +++ b/examples/basic-networking/terraform.tfvars @@ -0,0 +1,3 @@ +vpc-name = "DefaultVpc" +vpc-description = "Default Vpc" +vpc-cidr = "172.16.0.0/16" \ No newline at end of file diff --git a/examples/basic-networking/variables.tf b/examples/basic-networking/variables.tf new file mode 100644 index 0000000..6b2c7d8 --- /dev/null +++ b/examples/basic-networking/variables.tf @@ -0,0 +1,14 @@ +variable vpc-name { + type = string + description = "Name of VPC" +} + +variable vpc-description { + type = string + description = "Description of VPC" +} + +variable vpc-cidr { + type = string + description = "CIDR of VPC" +} \ No newline at end of file