diff --git a/.opencode/skills/link-info-extractor/SKILL.md b/.opencode/skills/link-info-extractor/SKILL.md new file mode 100644 index 000000000000..5ce21aad0ad0 --- /dev/null +++ b/.opencode/skills/link-info-extractor/SKILL.md @@ -0,0 +1,100 @@ +--- +name: link-info-extractor +description: Extract requirement details from a URL (Aone workitem, GitLab Code Review, etc.) using MCP tools. Use when the user provides a link to a requirement or review system. +metadata: + version: "2.0.0" + domain: requirements + triggers: aone link, workitem, code review, codereview, requirement url, extract from link +--- + +# Link Info Extractor + +When a user provides a URL pointing to a requirement or review system, use this skill to fetch and extract structured information from that link. + +## Supported Sources + +| Source | URL Pattern | Parameters to Extract | +|--------|------------|----------------------| +| Aone Workitem | `https://project.aone.alibaba-inc.com/v2/project//req/` | `projectId`, `workitemId` | +| GitLab Code Review | `https://code.alibaba-inc.com///codereview/` | `group`, `project`, `reviewId` | + +## Step 1: Identify the Source + +Match the URL against known patterns above to determine the source type. + +## Step 2: Fetch Information via MCP Tools + +### Source A: Aone Workitem + +1. Call `coop_query_workitem_detail(workitemId)` to get the workitem description, title, and status +2. Call `coop_get_workitem_comments(workitemId)` to get all comments + +> **Note:** The MCP tool name prefix (e.g., `coop_`) may vary across different app registrations, but the tool name suffix (`query_workitem_detail`, `get_workitem_comments`) stays the same. Always match by suffix. + +### Source B: GitLab Code Review + +Use the `alibaba_code` MCP to fetch Code Review information: + +1. Get Code Review details (description, status, changed files) +2. Get comments (may contain technical specs or requirement details) + +> **Note:** The MCP name prefix may vary across different app registrations, but the underlying tool names stay the same. Always match by suffix. + +## Step 3: Extract Structured Requirements + +From the fetched information, extract a structured technical spec. Focus on: + +1. **Attribute definitions** + - Attribute name (Terraform-side `snake_case` naming) + - Type (Boolean / String / Integer / List / Map, etc.) + - Required / Optional + - ForceNew (resource must be recreated on change) + - Computed (value returned by server) + +2. **API mapping** + - `requestPath` — parameter name for Create/Update API calls (typically PascalCase) + - `responsePath` — field name in Read API response + - Which API operations are involved: Create / Read / Update + +3. **Constraints** + - Default values + - Value range restrictions + - Mutual exclusion or dependencies with other attributes + - Minimum supported provider version + +## Output Format + +Return structured requirement info: + +``` +## Requirement Summary + +**Source**: []() +**Title**: + +### New Attributes + +| Attribute | Type | Required | ForceNew | Computed | Description | +|-----------|------|----------|----------|----------|-------------| +| <name> | <type> | <Y/N> | <Y/N> | <Y/N> | <description> | + +### API Mapping + +- **Create**: `<API name>` — request path: `<requestPath>` +- **Read**: `<API name>` — response path: `<responsePath>` +- **Update**: `<API name>` — request path: `<requestPath>` + +### Constraints + +- <constraint 1> +- <constraint 2> +- ... +``` + +## Important Notes + +1. Technical specs may appear in the description OR in comments — always check both +2. If the requirement is unclear, flag uncertain parts and ask the user to confirm +3. Extracted API parameter names must match Alibaba Cloud OpenAPI documentation +4. Distinguish which attributes support Update vs. Create-only (ForceNew) +5. This skill is NOT needed when the user describes requirements directly without a link diff --git a/.opencode/skills/provider-add-attribute/SKILL.md b/.opencode/skills/provider-add-attribute/SKILL.md new file mode 100644 index 000000000000..6a38ce5c45ef --- /dev/null +++ b/.opencode/skills/provider-add-attribute/SKILL.md @@ -0,0 +1,103 @@ +--- +name: provider-add-attribute +description: Add new attributes to an existing Terraform Provider resource. Covers the full workflow from code changes (Schema/Create/Read/Update), testing, documentation, to submitting a PR. +metadata: + version: "2.0.0" + domain: terraform-provider + triggers: add attribute, add field, new attribute, new field, resource attribute +--- + +# Add Attribute to Provider Resource + +Add one or more new attributes to an existing Terraform Provider resource. + +## Requirement Sources + +Requirements may come from: +- User's direct description +- An Aone workitem link +- A GitLab Code Review link + +If the user provides a link, use the `link-info-extractor` skill to extract requirement details first: +> `task(category="quick", load_skills=["link-info-extractor"], ...)` + +## Step 1: Prepare Development Environment + +```bash +cd <provider_repo_path> +git checkout master +git pull --rebase alicloud master +git checkout -b feat/<briefDescription> +``` + +Checkpoint: `git branch --show-current` should show the new branch name. + +## Step 2: Locate Target Files + +Find these four files: +- `alicloud/resource_alicloud_<product>_<resource>.go` — Schema + CRUD +- `alicloud/resource_alicloud_<product>_<resource>_test.go` — Tests +- `alicloud/service_alicloud_<product>[_v2].go` — Describe method (data source for Read) +- `website/docs/r/<product>_<resource>.html.markdown` — Documentation + +Find an existing attribute with the **same type and behavior** as a reference template (e.g., same `TypeBool` + `Optional` + `Computed` + `ForceNew` combination). + +Note: Attribute tags must be set based on actual requirements: +- `Computed` is NOT set by default. If tests show the new attribute causes a diff when unset (typically in existing test cases), add `Computed: true`. +- `ForceNew` should be set to `true` when the attribute does not support updates. + +## Step 3: Modify Code + +### Rules + +1. **Remove the auto-generated comment on line 1** once you modify a resource file: `// Package alicloud. This file is generated automatically...` +2. **Naming convention**: Terraform uses `snake_case` (e.g., `delete_on_release`), API uses `PascalCase` (e.g., `DeleteOnRelease`) +3. **Boolean attributes MUST use `GetOkExists`**: `GetOk` cannot distinguish `false` from unset (Go zero-value problem), causing `false` values to be silently dropped +4. **String / Integer attributes use `GetOk`** +5. **Do NOT use `v.(*schema.Set)` or `v.([]interface{})` for array type assertion** — use `convertToInterfaceArray` instead +6. **New attributes MUST have tests**. If the attribute is updatable, the update action MUST be tested +7. **Document the available-since version** for new attributes, e.g., `* \`tags\` - (Optional, Map, Available since v1.55.3) ...`. Use the upcoming version from CHANGELOG.md + +## Step 4: Verify + +```bash +# 1. Quick CI check +make ci-check-quick + +# 2. Full CI check (includes example tests and integration tests) +make ci-check + +# 3. If step 2 has test failures, debug with specific resource and test case: +make test-resource-debug RESOURCE=alicloud_vpc TESTCASE=TestAccAliCloudVPC_enableIpv6 LOGLEVEL=TRACE LOGFILE=vpc-test.log +``` + +## Step 5: Commit Code + +Squash all changes into **a single commit**: + +```bash +git status && git diff +make commit +git push origin feat/<brief_description> +``` + +Commit message format: +``` +feat(<resource_name>): add <attribute_name> attribute + +Closes: <requirement_url> +``` + +## Important Notes + +1. Skip unit tests — only run resource acceptance tests +2. All test failures (API errors, inventory issues, quota problems) must be resolved, never skipped +3. All changes should be squashed into a single git commit +4. Before adjusting API call parameters, use `aliyun <Product> <Action> help` to check API documentation + +## Acceptance Criteria + +1. Requirement is correctly implemented +2. New test cases pass (Create + Import + Update all PASS) +3. All existing test cases for the resource still pass +4. ci-check-quick and ci-check pass diff --git a/.opencode/skills/provider-fix-documentation/SKILL.md b/.opencode/skills/provider-fix-documentation/SKILL.md new file mode 100644 index 000000000000..da931424a10c --- /dev/null +++ b/.opencode/skills/provider-fix-documentation/SKILL.md @@ -0,0 +1,236 @@ +--- +name: provider-fix-documentation +description: Fix documentation issues in Terraform Provider resources. Covers attribute value corrections, description updates, example fixes, and documentation consistency checks. +metadata: + version: "1.0.0" + domain: terraform-provider + triggers: fix documentation, update docs, correct attribute values, documentation error, wrong description +--- + +# Fix Provider Documentation + +Fix documentation issues in Terraform Provider resources, including incorrect attribute values, outdated descriptions, missing information, or inconsistencies between code and documentation. + +## Requirement Sources + +Requirements may come from: +- User's direct description +- An Aone workitem link +- A GitLab Code Review link +- User-reported documentation errors + +If the user provides a link, use the `link-info-extractor` skill to extract requirement details first: +> `task(category="quick", load_skills=["link-info-extractor"], ...)` + +## Step 1: Identify the Issue + +Common documentation issues include: + +1. **Incorrect attribute values** — Valid values in docs don't match schema validation +2. **Outdated descriptions** — API behavior changed but docs weren't updated +3. **Missing attributes** — New attributes added to code but not documented +4. **Wrong examples** — Example code doesn't match current API or schema +5. **Inconsistent terminology** — Different terms used for same concept across docs +6. **Deprecated attributes** — Old attributes still documented without deprecation notice + +## Step 2: Locate Target Files + +Find the documentation file: +- `website/docs/r/<product>_<resource>.html.markdown` — Resource documentation +- `website/docs/d/<product>_<resource>.html.markdown` — Data source documentation + +Find the corresponding code file for verification: +- `alicloud/resource_alicloud_<product>_<resource>.go` — Schema definition +- `alicloud/data_source_alicloud_<product>_<resource>.go` — Data source schema + +## Step 3: Verify Against Code + +### For Attribute Value Issues + +1. **Find the schema definition** in the Go file: + ```go + "attribute_name": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: StringInSlice([]string{"Value1", "Value2"}, false), + } + ``` + +2. **Check the validation function** — The values in `StringInSlice` are the actual valid values + +3. **Check conversion functions** — Look for mapping between Terraform values and API values: + ```go + // Request conversion (Terraform → API) + if value == "Value1" { + request.ApiValue = "api_value_1" + } + + // Response conversion (API → Terraform) + if response.ApiValue == "api_value_1" { + terraformValue = "Value1" + } + ``` + +4. **Compare with documentation** — The docs should list the Terraform-side values (what users configure), NOT the API-side values + +### For Description Issues + +1. Check the schema `Description` field (if present) +2. Check API documentation via Alibaba Cloud OpenAPI Explorer +3. Verify against actual behavior in test files + +## Step 4: Fix Documentation + +### Rules + +1. **Use Terraform-side values** — Document the values users configure in Terraform, not internal API values +2. **Match schema exactly** — Valid values must match `ValidateFunc` in schema +3. **Clear mapping notes** — If there's a mapping between Terraform and API values, document it clearly +4. **Consistent formatting** — Follow existing documentation style: + ```markdown + * `attribute_name` - (Optional, Computed) Description. Supported values: + - `Value1`: Description of value 1 + - `Value2`: Description of value 2 + ``` +5. **Mark deprecated attributes** — Add deprecation notice with version and replacement: + ```markdown + * `old_attribute` - (Optional, Deprecated since v1.261.0) Description. Use `new_attribute` instead. + ``` +6. **Update available-since version** — For new attributes, add version info: + ```markdown + * `new_attribute` - (Optional, Available since v1.267.0) Description. + ``` + +### Common Fixes + +#### Fix 1: Incorrect Valid Values + +**Before:** +```markdown +* `payment_type` - (Optional) Billing method. Supported values: + - `prepaid`: Subscription + - `postpaid`: Pay-as-you-go +``` + +**After:** +```markdown +* `payment_type` - (Optional) Billing method. Supported values: + - `PayAsYouGo`: Pay-as-you-go + - `Subscription`: Subscription +``` + +#### Fix 2: Missing Deprecation Notice + +**Before:** +```markdown +* `instance_charge_type` - (Optional) Instance charge type. +``` + +**After:** +```markdown +* `instance_charge_type` - (Optional, Deprecated since v1.261.0) Instance charge type. Use `payment_type` instead. +``` + +#### Fix 3: Incomplete Value Descriptions + +**Before:** +```markdown +* `status` - (Optional) Instance status. Valid values: Active, Inactive. +``` + +**After:** +```markdown +* `status` - (Optional) Instance status. Supported values: + - `Active`: Instance is active and running + - `Inactive`: Instance is stopped +``` + +## Step 5: Verify + +1. **Check consistency** — Ensure all similar attributes follow the same documentation pattern +2. **Verify values** — Cross-reference with schema `ValidateFunc` in code +3. **Check examples** — If examples use the attribute, ensure they use correct values +4. **Search for related mentions** — Grep for the attribute name to find all mentions: + ```bash + grep -r "attribute_name" website/docs/ + ``` + +## Step 6: Commit Changes + +```bash +git status && git diff +make commit +git push origin fix/<brief_description> +``` + +Commit message format: +``` +docs(<resource_name>): fix <attribute_name> documentation + +- Correct valid values from <old_values> to <new_values> +- Update description to match schema definition + +Closes: <requirement_url> +``` + +## Step 7: Run CI Checks (MANDATORY) + +**After committing, you MUST run CI checks and ensure all pass:** + +```bash +# Run quick CI check (required for all documentation changes) +make ci-check-quick +``` + +**Checkpoint:** +- ✅ `make ci-check-quick` exits with code 0 +- ✅ No errors or warnings related to your changes +- ✅ Markdown linting passes +- ✅ Documentation format validation passes + +**If CI checks fail:** +1. Read the error message carefully +2. Fix the reported issues +3. Amend the commit: `git commit --amend` +4. Re-run `make ci-check-quick` +5. Repeat until all checks pass + +**DO NOT** skip this step or push code that fails CI checks. + +## Important Notes + +1. **Terraform values vs API values** — Users configure Terraform values, not API values. The provider handles mapping internally. +2. **Check conversion functions** — If values are mapped, ensure docs show Terraform-side values +3. **Schema is source of truth** — When in doubt, trust the schema `ValidateFunc` over existing docs +4. **Test files as reference** — Acceptance tests show actual valid values in use +5. **Don't change code** — This skill is for documentation fixes only. If code is wrong, use `provider-add-attribute` skill + +## Acceptance Criteria + +1. Documentation matches schema definition exactly +2. Valid values are correct and complete +3. Descriptions are clear and accurate +4. Consistent formatting with rest of documentation +5. Deprecation notices added where needed +6. All mentions of the attribute are updated consistently +7. **`make ci-check-quick` passes with exit code 0** (MANDATORY) + +## Example Workflow + +### Issue: User reports documentation error for payment_type + +1. **Read the workitem** to understand the reported issue +2. **Find the schema** in `resource_alicloud_elasticsearch_instance.go`: + ```go + "payment_type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: StringInSlice([]string{"PayAsYouGo", "Subscription"}, false), + } + ``` +3. **Find the docs** in `website/docs/r/elasticsearch_instance.html.markdown` +4. **Compare** — Docs say `prepaid`/`postpaid`, schema says `PayAsYouGo`/`Subscription` +5. **Fix docs** — Update to show correct Terraform values +6. **Verify** — Check no other mentions need updating +7. **Git Commit** — Single commit with clear message +8. **CI Check** — Run `make ci-check-quick` and ensure all checks pass ✅ diff --git a/CHANGELOG.md b/CHANGELOG.md index fa68798a0cd5..ed7ca8463df7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,34 @@ -## 1.272.0 (Unreleased) +## 1.273.0 (Unreleased) +## 1.272.1 (March 2, 2026) -- **New Resource:** `alicloud_live_domain` [GH-9513] +ENHANCEMENTS: +- resource/alicloud_esa_site: Added the field ai_mode, ai_template, global_mode. ([#9539](https://github.com/aliyun/terraform-provider-alicloud/issues/9539)) +- resource/alicloud_elasticsearch_instance: Added the field kibana_private_domain. ([#9540](https://github.com/aliyun/terraform-provider-alicloud/issues/9540)) + +## 1.272.0 (March 2, 2026) + +- **New Resource:** `alicloud_live_domain` ([#9513](https://github.com/aliyun/terraform-provider-alicloud/issues/9513)) ENHANCEMENTS: -- resource/alicloud_oos_patch_baseline: Support Fedora, Suse, RockyLinux for operation_system. [GH-9515] -- resource/alicloud_vpc_ipam_ipam: Added the field public_default_scope_id. [GH-9518] -- resource/alicloud_vpc_ipam_ipam_pool: Added the field ipv6_isp. [GH-9519] -- resource/alicloud_adb_db_cluster_lake_version: Removed the ForceNew for field payment_type; Supported for new action ModifyDBClusterPayType. [GH-9520] -- resource/alicloud_vpc_ipam_ipam_pool: marked ipv6_isp as Computed; resource/alicloud_vpc_ipam_ipam_pool_cidr: add new attribute netmask_length. [GH-9524] -- resource/alicloud_api_gateway_vpc_access: sort import, resource/alicloud_resource_manager_account: fix cannot update issue. [GH-9526] -- resource/alicloud_elasticsearch_instance: Fixed bug while creating enable_kibana_public_network with false. [GH-9528] -- resource/alicloud_resource_manager_account: Fixed the update error. [GH-9534] -- docs: Update max_compute_tenant_role_user_attachment document. [GH-9532] -- docs: Update ehpc_cluster document. [GH-9533] -- docs: Deprecated fc old version. [GH-9536] +- resource/alicloud_oos_patch_baseline: Support Fedora, Suse, RockyLinux for operation_system. ([#9515](https://github.com/aliyun/terraform-provider-alicloud/issues/9515)) +- resource/alicloud_vpc_ipam_ipam: Added the field public_default_scope_id. ([#9518](https://github.com/aliyun/terraform-provider-alicloud/issues/9518)) +- resource/alicloud_vpc_ipam_ipam_pool: Added the field ipv6_isp. ([#9519](https://github.com/aliyun/terraform-provider-alicloud/issues/9519)) +- resource/alicloud_adb_db_cluster_lake_version: Removed the ForceNew for field payment_type; Supported for new action ModifyDBClusterPayType. ([#9520](https://github.com/aliyun/terraform-provider-alicloud/issues/9520)) +- resource/alicloud_vpc_ipam_ipam_pool: marked ipv6_isp as Computed; resource/alicloud_vpc_ipam_ipam_pool_cidr: add new attribute netmask_length. ([#9524](https://github.com/aliyun/terraform-provider-alicloud/issues/9524)) +- resource/alicloud_api_gateway_vpc_access: sort import, resource/alicloud_resource_manager_account: fix cannot update issue. ([#9526](https://github.com/aliyun/terraform-provider-alicloud/issues/9526)) +- resource/alicloud_elasticsearch_instance: Fixed bug while creating enable_kibana_public_network with false. ([#9528](https://github.com/aliyun/terraform-provider-alicloud/issues/9528)) +- resource/alicloud_resource_manager_account: Fixed the update error. ([#9534](https://github.com/aliyun/terraform-provider-alicloud/issues/9534)) +- docs: Update max_compute_tenant_role_user_attachment document. ([#9532](https://github.com/aliyun/terraform-provider-alicloud/issues/9532)) +- docs: Update ehpc_cluster document. ([#9533](https://github.com/aliyun/terraform-provider-alicloud/issues/9533)) +- docs: Deprecated fc old version. ([#9536](https://github.com/aliyun/terraform-provider-alicloud/issues/9536)) BUG FIXES: -- resource/alicloud_ess_scaling_configuration: Fix when instance_type instance_types and instance_type_override do not set, only set instance_pattern_info exception. [GH-9516] -- resource/alicloud_resource_manager_account: Fixed the update error caused by field payer_account_id; Improved alicloud_resource_manager_account testcase. [GH-9517] -- resource/alicloud_db_instance: Fix parameter.max_connections is cannot update bug. [GH-9529] -- testcase: fix sweeper for vpc. [GH-9530] +- resource/alicloud_ess_scaling_configuration: Fix when instance_type instance_types and instance_type_override do not set, only set instance_pattern_info exception. ([#9516](https://github.com/aliyun/terraform-provider-alicloud/issues/9516)) +- resource/alicloud_resource_manager_account: Fixed the update error caused by field payer_account_id; Improved alicloud_resource_manager_account testcase. ([#9517](https://github.com/aliyun/terraform-provider-alicloud/issues/9517)) +- resource/alicloud_db_instance: Fix parameter.max_connections is cannot update bug. ([#9529](https://github.com/aliyun/terraform-provider-alicloud/issues/9529)) +- testcase: fix sweeper for vpc. ([#9530](https://github.com/aliyun/terraform-provider-alicloud/issues/9530)) ## 1.271.0 (February 11, 2026) diff --git a/GNUmakefile b/GNUmakefile index 97f7ae9d5f91..5485652f5bdb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -173,8 +173,9 @@ commit: # Local CI checks # Usage: -# make ci-check # Run all checks including example tests (default) +# make ci-check # Run all checks including example tests and resource integration tests (default) # make ci-check SKIP_EXAMPLE=1 # Run all checks except example tests +# make ci-check SKIP_TEST=1 # Skip resource integration tests # make ci-check SKIP_BUILD=1 # Skip build check # make ci-check-quick # Quick check (skip build, tests, errcheck, and example tests) ci-check: fmtcheck @@ -200,13 +201,14 @@ ci-check: fmtcheck if [ -d "bin" ]; then mv bin/terraform-provider-alicloud . && rmdir bin; fi; \ fi; \ fi - @if [ "$(SKIP_EXAMPLE)" = "1" ]; then \ - bash "$(CURDIR)/scripts/local-ci-check.sh" --skip-example-test --skip-build; \ - elif [ "$(SKIP_BUILD)" = "1" ]; then \ - bash "$(CURDIR)/scripts/local-ci-check.sh" --skip-build; \ - else \ - bash "$(CURDIR)/scripts/local-ci-check.sh" --skip-build; \ - fi + @CI_CHECK_FLAGS="--skip-build"; \ + if [ "$(SKIP_EXAMPLE)" = "1" ]; then \ + CI_CHECK_FLAGS="$$CI_CHECK_FLAGS --skip-example-test"; \ + fi; \ + if [ "$(SKIP_TEST)" = "1" ]; then \ + CI_CHECK_FLAGS="$$CI_CHECK_FLAGS --skip-resource-test"; \ + fi; \ + bash "$(CURDIR)/scripts/local-ci-check.sh" $$CI_CHECK_FLAGS # Quick CI check (skip build and tests) ci-check-quick: diff --git a/alicloud/connectivity/client.go b/alicloud/connectivity/client.go index 0705f64bebe4..1bed34d6a16c 100644 --- a/alicloud/connectivity/client.go +++ b/alicloud/connectivity/client.go @@ -180,7 +180,7 @@ var loadSdkfromRemoteMutex = sync.Mutex{} var loadSdkEndpointMutex = sync.Mutex{} // The main version number that is being run at the moment. -var providerVersion = "1.272.0" +var providerVersion = "1.272.1" // Temporarily maintain map for old ecs client methods and store special endpoint information var EndpointMap = map[string]string{ diff --git a/alicloud/data_source_alicloud_ram_groups.go b/alicloud/data_source_alicloud_ram_groups.go index 3b94554d7ac2..e5cfa56cfaf6 100644 --- a/alicloud/data_source_alicloud_ram_groups.go +++ b/alicloud/data_source_alicloud_ram_groups.go @@ -152,7 +152,7 @@ func dataSourceAlicloudRamGroupsRead(d *schema.ResourceData, meta interface{}) e addDebug(request.GetActionName(), raw, request.RpcRequest, request) return nil }) - if err != nil { + if err != nil && !NotFoundError(err) { return WrapErrorf(err, DataDefaultErrorMsg, "alicloud_ram_groups", request.GetActionName(), AlibabaCloudSdkGoERROR) } diff --git a/alicloud/provider.go b/alicloud/provider.go index f8e21a1ccaac..08e51d05493c 100644 --- a/alicloud/provider.go +++ b/alicloud/provider.go @@ -915,6 +915,7 @@ func Provider() terraform.ResourceProvider { "alicloud_vpc_ipam_ipams": dataSourceAliCloudVpcIpamIpams(), }, ResourcesMap: map[string]*schema.Resource{ + "alicloud_nlb_hd_monitor_region_config": resourceAliCloudNlbHdMonitorRegionConfig(), "alicloud_live_domain": resourceAliCloudLiveDomain(), "alicloud_oss_bucket_overwrite_config": resourceAliCloudOssBucketOverwriteConfig(), "alicloud_cloud_firewall_user_alarm_config": resourceAliCloudCloudFirewallUserAlarmConfig(), @@ -1295,7 +1296,7 @@ func Provider() terraform.ResourceProvider { "alicloud_db_read_write_splitting_connection": resourceAlicloudDBReadWriteSplittingConnection(), "alicloud_db_instance": resourceAliCloudDBInstance(), "alicloud_rds_whitelist_template": resourceAliCloudRdsWhitelistTemplate(), - "alicloud_rds_backup": resourceAlicloudRdsBackup(), + "alicloud_rds_backup": resourceAliCloudRdsBackup(), "alicloud_rds_db_proxy": resourceAlicloudRdsDBProxy(), "alicloud_rds_db_proxy_public": resourceAliCloudRdsDBProxyPublic(), "alicloud_rds_clone_db_instance": resourceAlicloudRdsCloneDbInstance(), @@ -1729,7 +1730,7 @@ func Provider() terraform.ResourceProvider { "alicloud_video_surveillance_system_group": resourceAlicloudVideoSurveillanceSystemGroup(), "alicloud_msc_sub_subscription": resourceAlicloudMscSubSubscription(), "alicloud_sddp_instance": resourceAlicloudSddpInstance(), - "alicloud_vpc_nat_ip_cidr": resourceAlicloudVpcNatIpCidr(), + "alicloud_vpc_nat_ip_cidr": resourceAliCloudNatGatewayNatIpCidr(), "alicloud_vpc_nat_ip": resourceAlicloudVpcNatIp(), "alicloud_quick_bi_user": resourceAlicloudQuickBiUser(), "alicloud_vod_domain": resourceAlicloudVodDomain(), @@ -1939,6 +1940,7 @@ func Provider() terraform.ResourceProvider { "alicloud_api_gateway_model": resourceAlicloudApiGatewayModel(), "alicloud_cen_transit_router_grant_attachment": resourceAlicloudCenTransitRouterGrantAttachment(), "alicloud_api_gateway_plugin": resourceAliCloudApiGatewayPlugin(), + "alicloud_api_gateway_group_plugin_attachment": resourceAlicloudApiGatewayGroupPluginAttachment(), "alicloud_api_gateway_plugin_attachment": resourceAlicloudApiGatewayPluginAttachment(), "alicloud_message_service_queue": resourceAliCloudMessageServiceQueue(), "alicloud_message_service_topic": resourceAliCloudMessageServiceTopic(), diff --git a/alicloud/resource_alicloud_api_gateway_group_plugin_attachment.go b/alicloud/resource_alicloud_api_gateway_group_plugin_attachment.go new file mode 100644 index 000000000000..4e10b2eb68dc --- /dev/null +++ b/alicloud/resource_alicloud_api_gateway_group_plugin_attachment.go @@ -0,0 +1,138 @@ +package alicloud + +import ( + "fmt" + "time" + + "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +func resourceAlicloudApiGatewayGroupPluginAttachment() *schema.Resource { + return &schema.Resource{ + Create: resourceAlicloudApiGatewayGroupPluginAttachmentCreate, + Read: resourceAlicloudApiGatewayGroupPluginAttachmentRead, + Delete: resourceAlicloudApiGatewayGroupPluginAttachmentDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "group_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "plugin_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "stage_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + } +} + +func resourceAlicloudApiGatewayGroupPluginAttachmentCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) + var response map[string]interface{} + action := "AttachGroupPlugin" + request := make(map[string]interface{}) + var err error + request["GroupId"] = d.Get("group_id") + request["PluginId"] = d.Get("plugin_id") + request["StageName"] = d.Get("stage_name") + wait := incrementalWait(3*time.Second, 3*time.Second) + err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { + response, err = client.RpcPost("CloudAPI", "2016-07-14", action, nil, request, false) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + addDebug(action, response, request) + return nil + }) + + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, "alicloud_api_gateway_group_plugin_attachment", action, AlibabaCloudSdkGoERROR) + } + + d.SetId(fmt.Sprint(request["GroupId"], ":", request["PluginId"], ":", request["StageName"])) + + return resourceAlicloudApiGatewayGroupPluginAttachmentRead(d, meta) +} + +func resourceAlicloudApiGatewayGroupPluginAttachmentRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) + apiGatewayServiceV2 := ApiGatewayServiceV2{client} + + objectRaw, err := apiGatewayServiceV2.DescribeApiGatewayGroupPluginAttachment(d.Id()) + + if err != nil { + if !d.IsNewResource() && NotFoundError(err) { + d.SetId("") + return nil + } + return WrapError(err) + } + + err = d.Set("group_id", objectRaw["GroupId"].(string)) + if err != nil { + return WrapError(err) + } + err = d.Set("stage_name", objectRaw["StageName"].(string)) + if err != nil { + return WrapError(err) + } + err = d.Set("plugin_id", objectRaw["PluginId"].(string)) + if err != nil { + return WrapError(err) + } + return nil + +} + +func resourceAlicloudApiGatewayGroupPluginAttachmentDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) + parts, err := ParseResourceId(d.Id(), 3) + if err != nil { + return WrapError(err) + } + var response map[string]interface{} + request := make(map[string]interface{}) + action := "DetachGroupPlugin" + request["RegionId"] = client.RegionId + request["GroupId"] = parts[0] + request["PluginId"] = parts[1] + request["StageName"] = parts[2] + + wait := incrementalWait(3*time.Second, 3*time.Second) + err = resource.Retry(client.GetRetryTimeout(d.Timeout(schema.TimeoutCreate)), func() *resource.RetryError { + response, err = client.RpcPost("CloudAPI", "2016-07-14", action, nil, request, false) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + addDebug(action, response, request) + return nil + }) + + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) + } + + return nil +} diff --git a/alicloud/resource_alicloud_api_gateway_group_plugin_attachment_test.go b/alicloud/resource_alicloud_api_gateway_group_plugin_attachment_test.go new file mode 100644 index 000000000000..e72bf19ec335 --- /dev/null +++ b/alicloud/resource_alicloud_api_gateway_group_plugin_attachment_test.go @@ -0,0 +1,87 @@ +package alicloud + +import ( + "fmt" + "testing" + + "github.com/aliyun/alibaba-cloud-sdk-go/services/cloudapi" + "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +func TestAccAliCloudApiGatewayGroupPluginAttachment(t *testing.T) { + var v *cloudapi.PluginAttribute + + resourceId := "alicloud_api_gateway_group_plugin_attachment.default" + ra := resourceAttrInit(resourceId, apiGatewayGroupPluginAttachmentBasicMap) + + rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { + return &ApiGatewayServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeApiGatewayGroupPluginAttachment") + + rac := resourceAttrCheckInit(rc, ra) + + testAccCheck := rac.resourceAttrMapUpdateSet() + rand := acctest.RandIntRange(1000000, 9999999) + name := fmt.Sprintf("tf_testAccGroupPlugin_%d", rand) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, resourceApiGatewayGroupPluginAttachmentConfigDependence) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + // module name + IDRefreshName: resourceId, + Providers: testAccProviders, + CheckDestroy: rac.checkResourceDestroy(), + Steps: []resource.TestStep{ + { + Config: testAccConfig(map[string]interface{}{ + "group_id": "${alicloud_api_gateway_group.default.id}", + "plugin_id": "${alicloud_api_gateway_plugin.default.id}", + "stage_name": "RELEASE", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "group_id": CHECKSET, + "plugin_id": CHECKSET, + "stage_name": "RELEASE", + }), + ), + }, + { + ResourceName: resourceId, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{}, + }, + }, + }) +} + +func resourceApiGatewayGroupPluginAttachmentConfigDependence(name string) string { + return fmt.Sprintf(` +variable "name" { + default = "%s" +} +resource "alicloud_api_gateway_group" "default" { + name = "${var.name}" + description = "tf_testAccApiGroup Description" +} + +resource "alicloud_api_gateway_plugin" "default" { + plugin_name = "${var.name}" + plugin_data = jsonencode({"allowOrigins": "api.foo.com","allowMethods": "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH","allowHeaders": "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid","exposeHeaders": "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message","maxAge": 172800,"allowCredentials": true}) + plugin_type = "cors" + description = "tf_testAccApiPlugin Description" +} + + `, name) +} + +var apiGatewayGroupPluginAttachmentBasicMap = map[string]string{ + "group_id": CHECKSET, + "plugin_id": CHECKSET, + "stage_name": "RELEASE", +} diff --git a/alicloud/resource_alicloud_config_aggregator.go b/alicloud/resource_alicloud_config_aggregator.go index 2e7a64333082..5d509ce530d0 100644 --- a/alicloud/resource_alicloud_config_aggregator.go +++ b/alicloud/resource_alicloud_config_aggregator.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "log" + "strconv" "time" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -162,7 +163,13 @@ func resourceAliCloudConfigAggregatorRead(d *schema.ResourceData, meta interface d.Set("aggregator_name", objectRaw["AggregatorName"]) d.Set("aggregator_type", objectRaw["AggregatorType"]) - d.Set("create_time", formatInt(objectRaw["AggregatorCreateTimestamp"])) + + createTime, err := strconv.ParseInt(objectRaw["AggregatorCreateTimestamp"].(json.Number).String(), 10, 64) + if err != nil { + return WrapError(err) + } + d.Set("create_time", createTime) + d.Set("description", objectRaw["Description"]) d.Set("folder_id", objectRaw["FolderId"]) d.Set("status", convertConfigAggregatorAggregatorAggregatorStatusResponse(objectRaw["AggregatorStatus"])) diff --git a/alicloud/resource_alicloud_dms_enterprise_instance.go b/alicloud/resource_alicloud_dms_enterprise_instance.go index 1c67c6b4bcbb..52199823a874 100644 --- a/alicloud/resource_alicloud_dms_enterprise_instance.go +++ b/alicloud/resource_alicloud_dms_enterprise_instance.go @@ -81,6 +81,10 @@ func resourceAlicloudDmsEnterpriseInstance() *schema.Resource { Required: true, ForceNew: true, }, + "sell_trust": { + Type: schema.TypeBool, + Required: true, + }, "data_link_name": { Type: schema.TypeString, Optional: true, @@ -170,7 +174,7 @@ func resourceAlicloudDmsEnterpriseInstance() *schema.Resource { func resourceAlicloudDmsEnterpriseInstanceCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) var response map[string]interface{} - action := "RegisterInstance" + action := "AddInstance" request := map[string]interface{}{ "DatabasePassword": d.Get("database_password").(string), "DatabaseUser": d.Get("database_user").(string), @@ -230,11 +234,17 @@ func resourceAlicloudDmsEnterpriseInstanceCreate(d *schema.ResourceData, meta in request["VpcId"] = v } + request["EnableSellTrust"] = "N" + sellTrust := d.Get("sell_trust").(bool) + if sellTrust { + request["EnableSellTrust"] = "Y" + } + wait := incrementalWait(3*time.Second, 2*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { response, err = client.RpcPost("dms-enterprise", "2018-11-01", action, nil, request, false) if err != nil { - if IsExpectedErrors(err, []string{"RegisterInstanceFailure"}) || NeedRetry(err) { + if IsExpectedErrors(err, []string{"AddInstanceFailure"}) || NeedRetry(err) { wait() return resource.RetryableError(err) } @@ -289,6 +299,7 @@ func resourceAlicloudDmsEnterpriseInstanceRead(d *schema.ResourceData, meta inte d.Set("use_dsql", formatInt(object["UseDsql"])) d.Set("vpc_id", object["VpcId"]) d.Set("dba_nick_name", object["DbaNickName"]) + d.Set("sell_trust", object["SellTrust"]) return nil } func resourceAlicloudDmsEnterpriseInstanceUpdate(d *schema.ResourceData, meta interface{}) error { @@ -383,6 +394,12 @@ func resourceAlicloudDmsEnterpriseInstanceUpdate(d *schema.ResourceData, meta in update = true request["VpcId"] = d.Get("vpc_id") } + + request["EnableSellTrust"] = "N" + if enableSellTrust := d.Get("sell_trust").(bool); enableSellTrust { + request["EnableSellTrust"] = "Y" + } + if update { if _, ok := d.GetOkExists("skip_test"); ok { request["SkipTest"] = d.Get("skip_test") @@ -390,7 +407,7 @@ func resourceAlicloudDmsEnterpriseInstanceUpdate(d *schema.ResourceData, meta in if _, ok := d.GetOk("tid"); ok { request["Tid"] = d.Get("tid") } - action := "UpdateInstance" + action := "ModifyInstance" wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { response, err = client.RpcPost("dms-enterprise", "2018-11-01", action, nil, request, false) diff --git a/alicloud/resource_alicloud_dms_enterprise_instance_test.go b/alicloud/resource_alicloud_dms_enterprise_instance_test.go index 352d4cf0a68d..d0730a507393 100644 --- a/alicloud/resource_alicloud_dms_enterprise_instance_test.go +++ b/alicloud/resource_alicloud_dms_enterprise_instance_test.go @@ -132,7 +132,9 @@ func TestAccAlicloudDMSEnterprise(t *testing.T) { "export_timeout": "2000", "ecs_region": os.Getenv("ALICLOUD_REGION"), "ddl_online": "0", + "sell_trust": "false", }), + ExpectNonEmptyPlan: true, // database_user will be encrypted if sell_trust=false Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ "dba_uid": CHECKSET, @@ -152,6 +154,7 @@ func TestAccAlicloudDMSEnterprise(t *testing.T) { "ddl_online": "0", "use_dsql": CHECKSET, "data_link_name": CHECKSET, + "sell_trust": "false", }), ), }, @@ -163,11 +166,15 @@ func TestAccAlicloudDMSEnterprise(t *testing.T) { }, { Config: testAccConfig(map[string]interface{}{ - "env_type": "dev", + "env_type": "dev", + "sell_trust": "true", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "env_type": "dev", + "env_type": "dev", + "sell_trust": "true", + // database_user will be plain text if sell_trust=true + "database_user": CHECKSET, }), ), }, diff --git a/alicloud/resource_alicloud_ecs_network_interface.go b/alicloud/resource_alicloud_ecs_network_interface.go index acd138d9ebf6..561909d7494b 100644 --- a/alicloud/resource_alicloud_ecs_network_interface.go +++ b/alicloud/resource_alicloud_ecs_network_interface.go @@ -178,6 +178,11 @@ func resourceAliCloudEcsNetworkInterface() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + "delete_on_release": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, }, } } @@ -267,6 +272,10 @@ func resourceAliCloudEcsNetworkInterfaceCreate(d *schema.ResourceData, meta inte request["SourceDestCheck"] = v } + if v, ok := d.GetOkExists("delete_on_release"); ok { + request["DeleteOnRelease"] = v + } + wait := incrementalWait(3*time.Second, 3*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { response, err = client.RpcPost("Ecs", "2014-05-26", action, nil, request, false) @@ -353,6 +362,7 @@ func resourceAliCloudEcsNetworkInterfaceRead(d *schema.ResourceData, meta interf d.Set("instance_type", object["Type"]) d.Set("network_interface_traffic_mode", object["NetworkInterfaceTrafficMode"]) d.Set("source_dest_check", object["SourceDestCheck"]) + d.Set("delete_on_release", object["DeleteOnRelease"]) return nil } @@ -411,6 +421,14 @@ func resourceAliCloudEcsNetworkInterfaceUpdate(d *schema.ResourceData, meta inte } } + if d.HasChange("delete_on_release") { + update = true + + if v, ok := d.GetOkExists("delete_on_release"); ok { + request["DeleteOnRelease"] = v + } + } + if update { action := "ModifyNetworkInterfaceAttribute" wait := incrementalWait(3*time.Second, 3*time.Second) @@ -437,6 +455,7 @@ func resourceAliCloudEcsNetworkInterfaceUpdate(d *schema.ResourceData, meta inte d.SetPartial("security_groups") d.SetPartial("security_group_ids") d.SetPartial("source_dest_check") + d.SetPartial("delete_on_release") if updateSecurityGroup { time.Sleep(500 * time.Millisecond) diff --git a/alicloud/resource_alicloud_ecs_network_interface_test.go b/alicloud/resource_alicloud_ecs_network_interface_test.go index 7b454a08c279..a00be3e1a7e7 100644 --- a/alicloud/resource_alicloud_ecs_network_interface_test.go +++ b/alicloud/resource_alicloud_ecs_network_interface_test.go @@ -830,6 +830,7 @@ func TestAccAliCloudECSNetworkInterface_basic4(t *testing.T) { "security_groups": []string{"${alicloud_security_group.default.0.id}"}, "resource_group_id": "${data.alicloud_resource_manager_resource_groups.default.ids.0}", "description": name, + "delete_on_release": "false", "private_ip_addresses": []string{fmt.Sprintf("${cidrhost(alicloud_vswitch.default.cidr_block, %d)}", rand), fmt.Sprintf("${cidrhost(alicloud_vswitch.default.cidr_block, %d)}", rand+1)}, "tags": map[string]string{ "Created": "TF-update", @@ -843,6 +844,7 @@ func TestAccAliCloudECSNetworkInterface_basic4(t *testing.T) { "security_groups.#": "1", "resource_group_id": CHECKSET, "description": name, + "delete_on_release": "false", "private_ips.#": "2", "tags.%": "2", "tags.Created": "TF-update", @@ -859,6 +861,72 @@ func TestAccAliCloudECSNetworkInterface_basic4(t *testing.T) { }) } +func TestAccAliCloudECSNetworkInterface_deleteOnRelease(t *testing.T) { + var v map[string]interface{} + resourceId := "alicloud_ecs_network_interface.default" + ra := resourceAttrInit(resourceId, AlicloudEcsNetworkInterfaceMap) + rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { + return &EcsService{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeEcsNetworkInterface") + rac := resourceAttrCheckInit(rc, ra) + testAccCheck := rac.resourceAttrMapUpdateSet() + rand := acctest.RandIntRange(2, 253) + name := fmt.Sprintf("tf-testacc%secsnetworkinterface%d", defaultRegionToTest, rand) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudEcsNetworkInterfaceBasicDependence) + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + IDRefreshName: resourceId, + Providers: testAccProviders, + CheckDestroy: rac.checkResourceDestroy(), + Steps: []resource.TestStep{ + { + Config: testAccConfig(map[string]interface{}{ + "network_interface_name": name, + "vswitch_id": "${alicloud_vswitch.default.id}", + "security_group_ids": []string{"${alicloud_security_group.default.0.id}"}, + "delete_on_release": "true", + "resource_group_id": "${data.alicloud_resource_manager_resource_groups.default.ids.0}", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "network_interface_name": CHECKSET, + "vswitch_id": CHECKSET, + "security_group_ids.#": "1", + "delete_on_release": "true", + }), + ), + }, + { + ResourceName: resourceId, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccConfig(map[string]interface{}{ + "delete_on_release": "false", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "delete_on_release": "false", + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "delete_on_release": "true", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "delete_on_release": "true", + }), + ), + }, + }, + }) +} + func TestAccAliCloudECSNetworkInterface_name_deprecated(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_ecs_network_interface.default" diff --git a/alicloud/resource_alicloud_elasticsearch_instance.go b/alicloud/resource_alicloud_elasticsearch_instance.go index 6f9acb9b99e4..ef662d41c3eb 100644 --- a/alicloud/resource_alicloud_elasticsearch_instance.go +++ b/alicloud/resource_alicloud_elasticsearch_instance.go @@ -183,6 +183,10 @@ func resourceAliCloudElasticsearchInstance() *schema.Resource { Type: schema.TypeInt, Computed: true, }, + "kibana_private_domain": { + Type: schema.TypeString, + Computed: true, + }, "kibana_private_security_group_id": { Type: schema.TypeString, Optional: true, @@ -844,6 +848,7 @@ func resourceAliCloudElasticsearchInstanceRead(d *schema.ResourceData, meta inte d.Set("instance_category", objectRaw["instanceCategory"]) d.Set("kibana_domain", objectRaw["kibanaDomain"]) d.Set("kibana_port", objectRaw["kibanaPort"]) + d.Set("kibana_private_domain", objectRaw["kibanaPrivateDomain"]) d.Set("payment_type", convertElasticsearchInstanceResultpaymentTypeResponse(objectRaw["paymentType"])) d.Set("instance_charge_type", getChargeType(objectRaw["paymentType"].(string))) d.Set("protocol", objectRaw["protocol"]) @@ -1837,7 +1842,7 @@ func resourceAliCloudElasticsearchInstanceUpdate(d *schema.ResourceData, meta in err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { response, err = client.RoaPost("elasticsearch", "2017-06-13", action, query, header, body, true) if err != nil { - if IsExpectedErrors(err, []string{"ConcurrencyUpdateInstanceConflict", "InstanceStatusNotSupportCurrentAction", "InstanceDuplicateScheduledTask"}) || NeedRetry(err) { + if IsExpectedErrors(err, []string{"ConcurrencyUpdateInstanceConflict", "InstanceDuplicateScheduledTask", "ServiceUnavailable", "InstanceStatusNotSupportCurrentAction"}) || NeedRetry(err) { wait() return resource.RetryableError(err) } @@ -2222,6 +2227,7 @@ func convertElasticsearchInstanceResultpaymentTypeResponse(source interface{}) i } return source } + func convertElasticsearchInstancepaymentTypeRequest(source interface{}) interface{} { source = fmt.Sprint(source) switch source { diff --git a/alicloud/resource_alicloud_esa_site.go b/alicloud/resource_alicloud_esa_site.go index 22d487842712..4890cebe5fd6 100644 --- a/alicloud/resource_alicloud_esa_site.go +++ b/alicloud/resource_alicloud_esa_site.go @@ -21,9 +21,9 @@ func resourceAliCloudEsaSite() *schema.Resource { State: schema.ImportStatePassthrough, }, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(5 * time.Minute), + Create: schema.DefaultTimeout(45 * time.Minute), Update: schema.DefaultTimeout(5 * time.Minute), - Delete: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(15 * time.Minute), }, Schema: map[string]*schema.Schema{ "access_type": { @@ -39,6 +39,16 @@ func resourceAliCloudEsaSite() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "ai_mode": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "ai_template": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "cache_architecture_mode": { Type: schema.TypeString, Optional: true, @@ -76,6 +86,11 @@ func resourceAliCloudEsaSite() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "global_mode": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "instance_id": { Type: schema.TypeString, Required: true, @@ -174,7 +189,7 @@ func resourceAliCloudEsaSiteCreate(d *schema.ResourceData, meta interface{}) err d.SetId(fmt.Sprint(response["SiteId"])) esaServiceV2 := EsaServiceV2{client} - stateConf := BuildStateConf([]string{}, []string{"pending"}, d.Timeout(schema.TimeoutCreate), 60*time.Second, esaServiceV2.EsaSiteStateRefreshFunc(d.Id(), "Status", []string{})) + stateConf := BuildStateConf([]string{}, []string{"pending"}, d.Timeout(schema.TimeoutCreate), 3*time.Minute, esaServiceV2.EsaSiteStateRefreshFuncWithApi(d.Id(), "Status", []string{}, esaServiceV2.DescribeEsaSite)) if _, err := stateConf.WaitForState(); err != nil { return WrapErrorf(err, IdMsg, d.Id()) } @@ -247,6 +262,14 @@ func resourceAliCloudEsaSiteRead(d *schema.ResourceData, meta interface{}) error d.Set("cache_reserve_enable", objectRaw["Enable"]) d.Set("cache_reserve_instance_id", objectRaw["CacheReserveInstanceId"]) + objectRaw, err = esaServiceV2.DescribeSiteDescribeHttpDDoSAttackIntelligentProtection(d.Id()) + if err != nil && !NotFoundError(err) { + return WrapError(err) + } + + d.Set("ai_mode", objectRaw["AiMode"]) + d.Set("ai_template", objectRaw["AiTemplate"]) + objectRaw, err = esaServiceV2.DescribeSiteGetTieredCache(d.Id()) if err != nil && !NotFoundError(err) { return WrapError(err) @@ -296,6 +319,12 @@ func resourceAliCloudEsaSiteRead(d *schema.ResourceData, meta interface{}) error d.Set("paused", objectRaw["Paused"]) + objectRaw, err = esaServiceV2.DescribeSiteDescribeHttpDDoSAttackProtection(d.Id()) + if err != nil && !NotFoundError(err) { + return WrapError(err) + } + + d.Set("global_mode", objectRaw["GlobalMode"]) return nil } @@ -398,7 +427,7 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } esaServiceV2 := EsaServiceV2{client} - stateConf := BuildStateConf([]string{}, []string{"pending"}, d.Timeout(schema.TimeoutUpdate), 10*time.Second, esaServiceV2.EsaSiteStateRefreshFunc(d.Id(), "Status", []string{})) + stateConf := BuildStateConf([]string{}, []string{"pending"}, d.Timeout(schema.TimeoutUpdate), 10*time.Second, esaServiceV2.EsaSiteStateRefreshFuncWithApi(d.Id(), "Status", []string{}, esaServiceV2.DescribeEsaSite)) if _, err := stateConf.WaitForState(); err != nil { return WrapErrorf(err, IdMsg, d.Id()) } @@ -475,6 +504,11 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err request["AddRealClientIpHeader"] = d.Get("add_real_client_ip_header") } + if d.HasChange("real_client_ip_header_name") { + update = true + request["RealClientIpHeaderName"] = d.Get("real_client_ip_header_name") + } + if d.HasChange("site_version") { update = true request["SiteVersion"] = d.Get("site_version") @@ -726,6 +760,66 @@ func resourceAliCloudEsaSiteUpdate(d *schema.ResourceData, meta interface{}) err request["Enable"] = d.Get("cache_reserve_enable") } + if update { + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { + response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) + } + } + update = false + action = "SetHttpDDoSAttackProtection" + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["SiteId"] = d.Id() + + if d.HasChange("global_mode") { + update = true + } + request["GlobalMode"] = d.Get("global_mode") + if update { + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { + response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) + } + } + update = false + action = "SetHttpDDoSAttackIntelligentProtection" + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["SiteId"] = d.Id() + + if d.HasChange("ai_template") { + update = true + } + request["AiTemplate"] = d.Get("ai_template") + if d.HasChange("ai_mode") { + update = true + } + request["AiMode"] = d.Get("ai_mode") if update { wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { diff --git a/alicloud/resource_alicloud_esa_site_test.go b/alicloud/resource_alicloud_esa_site_test.go index 4ca4815b5c70..a0630388bc4d 100644 --- a/alicloud/resource_alicloud_esa_site_test.go +++ b/alicloud/resource_alicloud_esa_site_test.go @@ -35,7 +35,7 @@ func TestAccAliCloudEsaSite_basic8490(t *testing.T) { "site_name": name, "coverage": "overseas", "access_type": "NS", - "instance_id": "${alicloud_esa_rate_plan_instance.defaultIEoDfU.id}", + "instance_id": "${data.alicloud_esa_sites.default.sites.0.instance_id}", "resource_group_id": "${data.alicloud_resource_manager_resource_groups.default.ids.1}", "paused": "false", }), @@ -60,6 +60,36 @@ func TestAccAliCloudEsaSite_basic8490(t *testing.T) { }), ), }, + { + Config: testAccConfig(map[string]interface{}{ + "global_mode": "weak", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "global_mode": "weak", + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "global_mode": "hard", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "global_mode": "hard", + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "global_mode": "default", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "global_mode": "default", + }), + ), + }, { Config: testAccConfig(map[string]interface{}{ "tags": map[string]string{ @@ -123,14 +153,8 @@ variable "name" { default = "%s" } -resource "alicloud_esa_rate_plan_instance" "defaultIEoDfU" { - type = "NS" - auto_renew = true - period = "1" - payment_type = "Subscription" - coverage = "overseas" - auto_pay = true - plan_name = "basic" +data "alicloud_esa_sites" "default" { + plan_subscribe_type = "enterpriseplan" } data "alicloud_resource_manager_resource_groups" "default" { diff --git a/alicloud/resource_alicloud_nlb_hd_monitor_region_config.go b/alicloud/resource_alicloud_nlb_hd_monitor_region_config.go new file mode 100644 index 000000000000..462166dd251c --- /dev/null +++ b/alicloud/resource_alicloud_nlb_hd_monitor_region_config.go @@ -0,0 +1,185 @@ +// Package alicloud. This file is generated automatically. Please do not modify it manually, thank you! +package alicloud + +import ( + "fmt" + "log" + "time" + + "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +func resourceAliCloudNlbHdMonitorRegionConfig() *schema.Resource { + return &schema.Resource{ + Create: resourceAliCloudNlbHdMonitorRegionConfigCreate, + Read: resourceAliCloudNlbHdMonitorRegionConfigRead, + Update: resourceAliCloudNlbHdMonitorRegionConfigUpdate, + Delete: resourceAliCloudNlbHdMonitorRegionConfigDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + }, + Schema: map[string]*schema.Schema{ + "log_project": { + Type: schema.TypeString, + Required: true, + }, + "metric_store": { + Type: schema.TypeString, + Required: true, + }, + "region_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAliCloudNlbHdMonitorRegionConfigCreate(d *schema.ResourceData, meta interface{}) error { + + client := meta.(*connectivity.AliyunClient) + + action := "SetHdMonitorRegionConfig" + var request map[string]interface{} + var response map[string]interface{} + query := make(map[string]interface{}) + var err error + request = make(map[string]interface{}) + if v, ok := d.GetOk("region_id"); ok { + request["RegionId"] = v + } + request["RegionId"] = client.RegionId + + request["LogProject"] = d.Get("log_project") + request["MetricStore"] = d.Get("metric_store") + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { + response, err = client.RpcPost("Nlb", "2022-04-30", action, query, request, true) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, "alicloud_nlb_hd_monitor_region_config", action, AlibabaCloudSdkGoERROR) + } + + d.SetId(fmt.Sprint(response["RegionId"])) + + return resourceAliCloudNlbHdMonitorRegionConfigRead(d, meta) +} + +func resourceAliCloudNlbHdMonitorRegionConfigRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) + nlbServiceV2 := NlbServiceV2{client} + + objectRaw, err := nlbServiceV2.DescribeNlbHdMonitorRegionConfig(d.Id()) + if err != nil { + if !d.IsNewResource() && NotFoundError(err) { + log.Printf("[DEBUG] Resource alicloud_nlb_hd_monitor_region_config DescribeNlbHdMonitorRegionConfig Failed!!! %s", err) + d.SetId("") + return nil + } + return WrapError(err) + } + + d.Set("log_project", objectRaw["LogProject"]) + d.Set("metric_store", objectRaw["MetricStore"]) + d.Set("region_id", objectRaw["RegionId"]) + + d.Set("region_id", d.Id()) + + return nil +} + +func resourceAliCloudNlbHdMonitorRegionConfigUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + update := false + + var err error + action := "SetHdMonitorRegionConfig" + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["RegionId"] = d.Id() + request["RegionId"] = client.RegionId + if d.HasChange("log_project") { + update = true + } + request["LogProject"] = d.Get("log_project") + if d.HasChange("metric_store") { + update = true + } + request["MetricStore"] = d.Get("metric_store") + if update { + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { + response, err = client.RpcPost("Nlb", "2022-04-30", action, query, request, true) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) + } + } + + return resourceAliCloudNlbHdMonitorRegionConfigRead(d, meta) +} + +func resourceAliCloudNlbHdMonitorRegionConfigDelete(d *schema.ResourceData, meta interface{}) error { + + client := meta.(*connectivity.AliyunClient) + action := "DeleteHdMonitorRegionConfig" + var request map[string]interface{} + var response map[string]interface{} + query := make(map[string]interface{}) + var err error + request = make(map[string]interface{}) + request["RegionId"] = d.Id() + request["RegionId"] = client.RegionId + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { + response, err = client.RpcPost("Nlb", "2022-04-30", action, query, request, true) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + + if err != nil { + if IsExpectedErrors(err, []string{"ResourceNotFound.RegionHdMonitorConfig"}) || NotFoundError(err) { + return nil + } + return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) + } + + return nil +} diff --git a/alicloud/resource_alicloud_nlb_hd_monitor_region_config_test.go b/alicloud/resource_alicloud_nlb_hd_monitor_region_config_test.go new file mode 100644 index 000000000000..9acb50328cf4 --- /dev/null +++ b/alicloud/resource_alicloud_nlb_hd_monitor_region_config_test.go @@ -0,0 +1,84 @@ +// Package alicloud. This file is generated automatically. Please do not modify it manually, thank you! +package alicloud + +import ( + "fmt" + "testing" + + "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" +) + +// Test Nlb HdMonitorRegionConfig. >>> Resource test cases, automatically generated. +// Case hdMonitor 9477 +func TestAccAliCloudNlbHdMonitorRegionConfig_basic9477(t *testing.T) { + var v map[string]interface{} + resourceId := "alicloud_nlb_hd_monitor_region_config.default" + ra := resourceAttrInit(resourceId, AlicloudNlbHdMonitorRegionConfigMap9477) + rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { + return &NlbServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeNlbHdMonitorRegionConfig") + rac := resourceAttrCheckInit(rc, ra) + testAccCheck := rac.resourceAttrMapUpdateSet() + rand := acctest.RandIntRange(10000, 99999) + name := fmt.Sprintf("tfaccnlb%d", rand) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudNlbHdMonitorRegionConfigBasicDependence9477) + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheckWithRegions(t, true, []connectivity.Region{"cn-beijing"}) + testAccPreCheck(t) + }, + IDRefreshName: resourceId, + Providers: testAccProviders, + CheckDestroy: rac.checkResourceDestroy(), + Steps: []resource.TestStep{ + { + Config: testAccConfig(map[string]interface{}{ + "metric_store": "test", + "log_project": "test", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "metric_store": "test", + "log_project": "test", + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "metric_store": "test2", + "log_project": "test2", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "metric_store": "test2", + "log_project": "test2", + }), + ), + }, + { + ResourceName: resourceId, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{}, + }, + }, + }) +} + +var AlicloudNlbHdMonitorRegionConfigMap9477 = map[string]string{ + "region_id": CHECKSET, +} + +func AlicloudNlbHdMonitorRegionConfigBasicDependence9477(name string) string { + return fmt.Sprintf(` +variable "name" { + default = "%s" +} + + +`, name) +} + +// Test Nlb HdMonitorRegionConfig. <<< Resource test cases, automatically generated. diff --git a/alicloud/resource_alicloud_rds_backup.go b/alicloud/resource_alicloud_rds_backup.go index a6707f92be21..35c462dacc00 100644 --- a/alicloud/resource_alicloud_rds_backup.go +++ b/alicloud/resource_alicloud_rds_backup.go @@ -10,26 +10,35 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) -func resourceAlicloudRdsBackup() *schema.Resource { +func resourceAliCloudRdsBackup() *schema.Resource { return &schema.Resource{ - Create: resourceAlicloudRdsBackupCreate, - Read: resourceAlicloudRdsBackupRead, - Update: resourceAlicloudRdsBackupUpdate, - Delete: resourceAlicloudRdsBackupDelete, + Create: resourceAliCloudRdsBackupCreate, + Read: resourceAliCloudRdsBackupRead, + Update: resourceAliCloudRdsBackupUpdate, + Delete: resourceAliCloudRdsBackupDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), + Create: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), }, Schema: map[string]*schema.Schema{ + "backup_id": { + Type: schema.TypeString, + Computed: true, + }, "backup_method": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + "backup_retention_period": { + Type: schema.TypeInt, + Optional: true, + }, "backup_strategy": { Type: schema.TypeString, Optional: true, @@ -49,46 +58,53 @@ func resourceAlicloudRdsBackup() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "backup_id": { + "status": { Type: schema.TypeString, Computed: true, }, - "remove_from_state": { - Type: schema.TypeBool, - Optional: true, - }, "store_status": { Type: schema.TypeString, Computed: true, }, + "remove_from_state": { + Type: schema.TypeBool, + Optional: true, + }, }, } } -func resourceAlicloudRdsBackupCreate(d *schema.ResourceData, meta interface{}) error { +func resourceAliCloudRdsBackupCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) rdsService := RdsService{client} - var response map[string]interface{} action := "CreateBackup" - request := make(map[string]interface{}) - request["SourceIp"] = client.SourceIp + var request map[string]interface{} + var response map[string]interface{} + query := make(map[string]interface{}) var err error + request = make(map[string]interface{}) + request["RegionId"] = client.RegionId + if v, ok := d.GetOk("backup_method"); ok { request["BackupMethod"] = v } + if v, ok := d.GetOkExists("backup_retention_period"); ok { + request["BackupRetentionPeriod"] = v + } + request["DBInstanceId"] = d.Get("db_instance_id") if v, ok := d.GetOk("backup_strategy"); ok { request["BackupStrategy"] = v } if v, ok := d.GetOk("backup_type"); ok { request["BackupType"] = v } - request["DBInstanceId"] = d.Get("db_instance_id") if v, ok := d.GetOk("db_name"); ok { request["DBName"] = v } wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - response, err = client.RpcPost("Rds", "2014-08-15", action, nil, request, false) + response, err = client.RpcPost("Rds", "2014-08-15", action, query, request, true) if err != nil { if IsExpectedErrors(err, []string{"BackupJobExists"}) || NeedRetry(err) { wait() @@ -99,6 +115,7 @@ func resourceAlicloudRdsBackupCreate(d *schema.ResourceData, meta interface{}) e return nil }) addDebug(action, response, request) + if err != nil { return WrapErrorf(err, DefaultErrorMsg, "alicloud_rds_backup", action, AlibabaCloudSdkGoERROR) } @@ -110,37 +127,43 @@ func resourceAlicloudRdsBackupCreate(d *schema.ResourceData, meta interface{}) e time.Sleep(1 * time.Minute) object, err := rdsService.DescribeBackupTasks(d.Get("db_instance_id").(string), response["BackupJobId"].(string)) d.SetId(fmt.Sprint(request["DBInstanceId"], ":", object["BackupId"].(string))) - return resourceAlicloudRdsBackupRead(d, meta) + + return resourceAliCloudRdsBackupRead(d, meta) } -func resourceAlicloudRdsBackupRead(d *schema.ResourceData, meta interface{}) error { +func resourceAliCloudRdsBackupRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - rdsService := RdsService{client} - object, err := rdsService.DescribeRdsBackup(d.Id()) + rdsServiceV2 := RdsServiceV2{client} + + objectRaw, err := rdsServiceV2.DescribeRdsBackup(d.Id()) if err != nil { - if NotFoundError(err) { - log.Printf("[DEBUG] Resource alicloud_rds_backup rdsService.DescribeRdsBackup Failed!!! %s", err) + if !d.IsNewResource() && NotFoundError(err) { + log.Printf("[DEBUG] Resource alicloud_rds_backup DescribeRdsBackup Failed!!! %s", err) d.SetId("") return nil } return WrapError(err) } - d.Set("backup_method", object["BackupMethod"]) - d.Set("backup_type", object["BackupType"]) - d.Set("db_instance_id", object["DBInstanceId"]) - d.Set("backup_id", object["BackupId"]) - d.Set("store_status", object["StoreStatus"]) + d.Set("backup_method", objectRaw["BackupMethod"]) + d.Set("backup_type", objectRaw["BackupType"]) + d.Set("db_instance_id", objectRaw["DBInstanceId"]) + d.Set("status", objectRaw["MetaStatus"]) + d.Set("store_status", objectRaw["StoreStatus"]) + d.Set("backup_id", objectRaw["BackupId"]) + return nil } -func resourceAlicloudRdsBackupUpdate(d *schema.ResourceData, meta interface{}) error { - log.Println(fmt.Sprintf("[WARNING] The resouce has not update operation.")) - return resourceAlicloudRdsBackupRead(d, meta) + +func resourceAliCloudRdsBackupUpdate(d *schema.ResourceData, meta interface{}) error { + log.Printf("[INFO] Cannot update resource Alicloud Resource Backup.") + return nil } -func resourceAlicloudRdsBackupDelete(d *schema.ResourceData, meta interface{}) error { + +func resourceAliCloudRdsBackupDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) action := "DeleteBackup" - parts, err := ParseResourceId(d.Id(), 2) if d.Get("store_status").(string) == "Disabled" { if !d.Get("remove_from_state").(bool) { return WrapError(Error("the resource can not be deleted at this time and you can set remove_from_state to true to remove it.")) @@ -148,14 +171,18 @@ func resourceAlicloudRdsBackupDelete(d *schema.ResourceData, meta interface{}) e return nil } } + var request map[string]interface{} var response map[string]interface{} - request := map[string]interface{}{ - "BackupId": parts[1], - "DBInstanceId": parts[0], - } + query := make(map[string]interface{}) + var err error + request = make(map[string]interface{}) + request["BackupId"] = d.Id() + request["RegionId"] = client.RegionId + + request["DBInstanceId"] = d.Get("db_instance_id") wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - response, err = client.RpcPost("Rds", "2014-08-15", action, nil, request, false) + response, err = client.RpcPost("Rds", "2014-08-15", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -166,8 +193,13 @@ func resourceAlicloudRdsBackupDelete(d *schema.ResourceData, meta interface{}) e return nil }) addDebug(action, response, request) + if err != nil { + if NotFoundError(err) { + return nil + } return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } + return nil } diff --git a/alicloud/resource_alicloud_rds_backup_test.go b/alicloud/resource_alicloud_rds_backup_test.go index cd3031ca793a..22e7e64eef3e 100644 --- a/alicloud/resource_alicloud_rds_backup_test.go +++ b/alicloud/resource_alicloud_rds_backup_test.go @@ -145,6 +145,7 @@ func TestAccAliCloudRdsBackup_PostgreSQL(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) + testAccPreCheckWithRegions(t, true, []connectivity.Region{"cn-hangzhou"}) }, IDRefreshName: resourceId, Providers: testAccProviders, @@ -297,12 +298,13 @@ func TestAccAliCloudRdsBackup_SQLServer1(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccConfig(map[string]interface{}{ - "db_instance_id": "${alicloud_db_instance.default.id}", - "backup_strategy": "db", - "backup_method": "Physical", - "backup_type": "FullBackup", - "db_name": "${alicloud_db_database.default.name}", - "remove_from_state": "true", + "db_instance_id": "${alicloud_db_instance.default.id}", + "backup_strategy": "db", + "backup_method": "Physical", + "backup_type": "FullBackup", + "backup_retention_period": "7", + "db_name": "${alicloud_db_database.default.name}", + "remove_from_state": "true", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ @@ -318,7 +320,7 @@ func TestAccAliCloudRdsBackup_SQLServer1(t *testing.T) { ResourceName: resourceId, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"remove_from_state", "db_name", "backup_strategy"}, + ImportStateVerifyIgnore: []string{"remove_from_state", "db_name", "backup_strategy", "backup_retention_period"}, }, }, }) @@ -483,7 +485,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { StatusCode: tea.Int(400), } }) - err := resourceAlicloudRdsBackupCreate(d, rawClient) + err := resourceAliCloudRdsBackupCreate(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -500,7 +502,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["CreateNormal"]("") }) - err := resourceAlicloudRdsBackupCreate(d, rawClient) + err := resourceAliCloudRdsBackupCreate(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -517,7 +519,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["CreateNormal"]("") }) - err := resourceAlicloudRdsBackupCreate(dCreate, rawClient) + err := resourceAliCloudRdsBackupCreate(dCreate, rawClient) patches.Reset() assert.Nil(t, err) }) @@ -529,7 +531,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { patcheDescribeBackups := gomonkey.ApplyMethod(reflect.TypeOf(&RdsService{}), "DescribeRdsBackup", func(*RdsService, string) (map[string]interface{}, error) { return responseMock["UpdateNormal"]("") }) - err := resourceAlicloudRdsBackupUpdate(d, rawClient) + err := resourceAliCloudRdsBackupUpdate(d, rawClient) patcheDescribeBackups.Reset() assert.Nil(t, err) }) @@ -544,7 +546,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { StatusCode: tea.Int(400), } }) - err := resourceAlicloudRdsBackupDelete(d, rawClient) + err := resourceAliCloudRdsBackupDelete(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -561,7 +563,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["DeleteNormal"]("") }) - err := resourceAlicloudRdsBackupDelete(d, rawClient) + err := resourceAliCloudRdsBackupDelete(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -579,7 +581,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { return responseMock["DeleteNormal"]("") }) - err := resourceAlicloudRdsBackupDelete(d, rawClient) + err := resourceAliCloudRdsBackupDelete(d, rawClient) patches.Reset() assert.Nil(t, err) }) @@ -596,7 +598,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["DeleteNormal"]("") }) - err := resourceAlicloudRdsBackupDelete(d, rawClient) + err := resourceAliCloudRdsBackupDelete(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -617,7 +619,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["DeleteNormal"]("") }) - err := resourceAlicloudRdsBackupDelete(resourceData, rawClient) + err := resourceAliCloudRdsBackupDelete(resourceData, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -634,7 +636,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["ReadNormal"]("") }) - err := resourceAlicloudRdsBackupRead(d, rawClient) + err := resourceAliCloudRdsBackupRead(d, rawClient) patcheDorequest.Reset() assert.Nil(t, err) }) @@ -650,7 +652,7 @@ func TestUnitAlicloudRdsBackup(t *testing.T) { } return responseMock["ReadNormal"]("") }) - err := resourceAlicloudRdsBackupRead(d, rawClient) + err := resourceAliCloudRdsBackupRead(d, rawClient) patcheDorequest.Reset() assert.NotNil(t, err) }) diff --git a/alicloud/resource_alicloud_vpc_nat_ip_cidr.go b/alicloud/resource_alicloud_vpc_nat_ip_cidr.go index 8c59727b5edf..e8b3062ca76b 100644 --- a/alicloud/resource_alicloud_vpc_nat_ip_cidr.go +++ b/alicloud/resource_alicloud_vpc_nat_ip_cidr.go @@ -1,8 +1,10 @@ +// Package alicloud. This file is generated automatically. Please do not modify it manually, thank you! package alicloud import ( "fmt" "log" + "strings" "time" "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" @@ -10,20 +12,28 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) -func resourceAlicloudVpcNatIpCidr() *schema.Resource { +func resourceAliCloudNatGatewayNatIpCidr() *schema.Resource { return &schema.Resource{ - Create: resourceAlicloudVpcNatIpCidrCreate, - Read: resourceAlicloudVpcNatIpCidrRead, - Update: resourceAlicloudVpcNatIpCidrUpdate, - Delete: resourceAlicloudVpcNatIpCidrDelete, + Create: resourceAliCloudNatGatewayNatIpCidrCreate, + Read: resourceAliCloudNatGatewayNatIpCidrRead, + Update: resourceAliCloudNatGatewayNatIpCidrUpdate, + Delete: resourceAliCloudNatGatewayNatIpCidrDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + }, Schema: map[string]*schema.Schema{ + "create_time": { + Type: schema.TypeString, + Computed: true, + }, "dry_run": { Type: schema.TypeBool, Optional: true, - Computed: true, }, "nat_gateway_id": { Type: schema.TypeString, @@ -32,7 +42,7 @@ func resourceAlicloudVpcNatIpCidr() *schema.Resource { }, "nat_ip_cidr": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "nat_ip_cidr_description": { @@ -41,7 +51,7 @@ func resourceAlicloudVpcNatIpCidr() *schema.Resource { }, "nat_ip_cidr_name": { Type: schema.TypeString, - Optional: true, + Required: true, }, "status": { Type: schema.TypeString, @@ -51,30 +61,35 @@ func resourceAlicloudVpcNatIpCidr() *schema.Resource { } } -func resourceAlicloudVpcNatIpCidrCreate(d *schema.ResourceData, meta interface{}) error { +func resourceAliCloudNatGatewayNatIpCidrCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) - var response map[string]interface{} + action := "CreateNatIpCidr" - request := make(map[string]interface{}) + var request map[string]interface{} + var response map[string]interface{} + query := make(map[string]interface{}) var err error - if v, ok := d.GetOkExists("dry_run"); ok { - request["DryRun"] = v - } - request["NatGatewayId"] = d.Get("nat_gateway_id") + request = make(map[string]interface{}) if v, ok := d.GetOk("nat_ip_cidr"); ok { request["NatIpCidr"] = v } + if v, ok := d.GetOk("nat_gateway_id"); ok { + request["NatGatewayId"] = v + } + request["RegionId"] = client.RegionId + request["ClientToken"] = buildClientToken(action) + if v, ok := d.GetOk("nat_ip_cidr_description"); ok { request["NatIpCidrDescription"] = v } - if v, ok := d.GetOk("nat_ip_cidr_name"); ok { - request["NatIpCidrName"] = v + if v, ok := d.GetOkExists("dry_run"); ok { + request["DryRun"] = v } - request["RegionId"] = client.RegionId - wait := incrementalWait(3*time.Second, 3*time.Second) + request["NatIpCidrName"] = d.Get("nat_ip_cidr_name") + wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - request["ClientToken"] = buildClientToken("CreateNatIpCidr") - response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) + response, err = client.RpcPost("Vpc", "2016-04-28", action, query, request, true) if err != nil { if IsExpectedErrors(err, []string{"OperationConflict"}) || NeedRetry(err) { wait() @@ -85,74 +100,72 @@ func resourceAlicloudVpcNatIpCidrCreate(d *schema.ResourceData, meta interface{} return nil }) addDebug(action, response, request) + if err != nil { return WrapErrorf(err, DefaultErrorMsg, "alicloud_vpc_nat_ip_cidr", action, AlibabaCloudSdkGoERROR) } - d.SetId(fmt.Sprint(request["NatGatewayId"], ":", request["NatIpCidr"])) + d.SetId(fmt.Sprintf("%v:%v", request["NatGatewayId"], request["NatIpCidr"])) - return resourceAlicloudVpcNatIpCidrRead(d, meta) + return resourceAliCloudNatGatewayNatIpCidrRead(d, meta) } -func resourceAlicloudVpcNatIpCidrRead(d *schema.ResourceData, meta interface{}) error { + +func resourceAliCloudNatGatewayNatIpCidrRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) - vpcService := VpcService{client} - object, err := vpcService.DescribeVpcNatIpCidr(d.Id()) + nATGatewayServiceV2 := NATGatewayServiceV2{client} + + objectRaw, err := nATGatewayServiceV2.DescribeNatGatewayNatIpCidr(d.Id()) if err != nil { - if NotFoundError(err) { - log.Printf("[DEBUG] Resource alicloud_vpc_nat_ip_cidr vpcService.DescribeVpcNatIpCidr Failed!!! %s", err) + if !d.IsNewResource() && NotFoundError(err) { + log.Printf("[DEBUG] Resource alicloud_vpc_nat_ip_cidr DescribeNatGatewayNatIpCidr Failed!!! %s", err) d.SetId("") return nil } return WrapError(err) } - parts, err := ParseResourceId(d.Id(), 2) - if err != nil { - return WrapError(err) - } - d.Set("nat_gateway_id", parts[0]) - d.Set("nat_ip_cidr", parts[1]) - d.Set("nat_ip_cidr_description", object["NatIpCidrDescription"]) - d.Set("nat_ip_cidr_name", object["NatIpCidrName"]) - d.Set("status", object["NatIpCidrStatus"]) + + d.Set("create_time", objectRaw["CreationTime"]) + d.Set("nat_ip_cidr_description", objectRaw["NatIpCidrDescription"]) + d.Set("nat_ip_cidr_name", objectRaw["NatIpCidrName"]) + d.Set("status", objectRaw["NatIpCidrStatus"]) + d.Set("nat_gateway_id", objectRaw["NatGatewayId"]) + d.Set("nat_ip_cidr", objectRaw["NatIpCidr"]) + return nil } -func resourceAlicloudVpcNatIpCidrUpdate(d *schema.ResourceData, meta interface{}) error { + +func resourceAliCloudNatGatewayNatIpCidrUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*connectivity.AliyunClient) + var request map[string]interface{} var response map[string]interface{} - parts, err := ParseResourceId(d.Id(), 2) - if err != nil { - return WrapError(err) - } + var query map[string]interface{} update := false - request := map[string]interface{}{ - "NatGatewayId": parts[0], - "NatIpCidr": parts[1], - } - if d.HasChange("nat_ip_cidr_name") { + + var err error + parts := strings.Split(d.Id(), ":") + action := "ModifyNatIpCidrAttribute" + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["NatIpCidr"] = parts[1] + request["NatGatewayId"] = parts[0] + request["RegionId"] = client.RegionId + request["ClientToken"] = buildClientToken(action) + if d.HasChange("nat_ip_cidr_description") { update = true + request["NatIpCidrDescription"] = d.Get("nat_ip_cidr_description") } - if v, ok := d.GetOk("nat_ip_cidr_name"); ok { - request["NatIpCidrName"] = v + + if v, ok := d.GetOkExists("dry_run"); ok { + request["DryRun"] = v } - request["RegionId"] = client.RegionId - if d.HasChange("dry_run") || d.IsNewResource() { + if d.HasChange("nat_ip_cidr_name") { update = true - if v, ok := d.GetOkExists("dry_run"); ok { - request["DryRun"] = v - } - } - if d.HasChange("nat_ip_cidr_description") { - update = true - if v, ok := d.GetOk("nat_ip_cidr_description"); ok { - request["NatIpCidrDescription"] = v - } } + request["NatIpCidrName"] = d.Get("nat_ip_cidr_name") if update { - action := "ModifyNatIpCidrAttribute" - wait := incrementalWait(3*time.Second, 3*time.Second) + wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError { - request["ClientToken"] = buildClientToken("ModifyNatIpCidrAttribute") - response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) + response, err = client.RpcPost("Vpc", "2016-04-28", action, query, request, true) if err != nil { if NeedRetry(err) { wait() @@ -167,29 +180,31 @@ func resourceAlicloudVpcNatIpCidrUpdate(d *schema.ResourceData, meta interface{} return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } } - return resourceAlicloudVpcNatIpCidrRead(d, meta) + + return resourceAliCloudNatGatewayNatIpCidrRead(d, meta) } -func resourceAlicloudVpcNatIpCidrDelete(d *schema.ResourceData, meta interface{}) error { + +func resourceAliCloudNatGatewayNatIpCidrDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*connectivity.AliyunClient) - parts, err := ParseResourceId(d.Id(), 2) - if err != nil { - return WrapError(err) - } + parts := strings.Split(d.Id(), ":") action := "DeleteNatIpCidr" + var request map[string]interface{} var response map[string]interface{} - request := map[string]interface{}{ - "NatGatewayId": parts[0], - "NatIpCidr": parts[1], - } + query := make(map[string]interface{}) + var err error + request = make(map[string]interface{}) + request["NatIpCidr"] = parts[1] + request["NatGatewayId"] = parts[0] + request["RegionId"] = client.RegionId + request["ClientToken"] = buildClientToken(action) if v, ok := d.GetOkExists("dry_run"); ok { request["DryRun"] = v } - request["RegionId"] = client.RegionId - wait := incrementalWait(3*time.Second, 3*time.Second) + wait := incrementalWait(3*time.Second, 5*time.Second) err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError { - request["ClientToken"] = buildClientToken("DeleteNatIpCidr") - response, err = client.RpcPost("Vpc", "2016-04-28", action, nil, request, true) + response, err = client.RpcPost("Vpc", "2016-04-28", action, query, request, true) if err != nil { if IsExpectedErrors(err, []string{"OperationConflict"}) || NeedRetry(err) { wait() @@ -200,8 +215,13 @@ func resourceAlicloudVpcNatIpCidrDelete(d *schema.ResourceData, meta interface{} return nil }) addDebug(action, response, request) + if err != nil { + if NotFoundError(err) { + return nil + } return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } + return nil } diff --git a/alicloud/resource_alicloud_vpc_nat_ip_cidr_test.go b/alicloud/resource_alicloud_vpc_nat_ip_cidr_test.go index d09e7fc4e0a3..d1f4355cb1e8 100644 --- a/alicloud/resource_alicloud_vpc_nat_ip_cidr_test.go +++ b/alicloud/resource_alicloud_vpc_nat_ip_cidr_test.go @@ -19,18 +19,20 @@ import ( "github.com/stretchr/testify/assert" ) -func TestAccAlicloudVPCNatIpCidr_basic0(t *testing.T) { +// Test NatGateway NatIpCidr. >>> Resource test cases, automatically generated. +// Case 全生命周期_NatIpCidr_1.0.0 12366 +func TestAccAliCloudNatGatewayNatIpCidr_basic12366(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_vpc_nat_ip_cidr.default" - ra := resourceAttrInit(resourceId, AlicloudVPCNatIpCidrMap0) + ra := resourceAttrInit(resourceId, AliCloudNatGatewayNatIpCidrMap12366) rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { - return &VpcService{testAccProvider.Meta().(*connectivity.AliyunClient)} - }, "DescribeVpcNatIpCidr") + return &NATGatewayServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeNatGatewayNatIpCidr") rac := resourceAttrCheckInit(rc, ra) testAccCheck := rac.resourceAttrMapUpdateSet() rand := acctest.RandIntRange(10000, 99999) - name := fmt.Sprintf("tf-testacc%svpcnatipcidr%d", defaultRegionToTest, rand) - testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudVPCNatIpCidrBasicDependence0) + name := fmt.Sprintf("tfaccnatgateway%d", rand) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudNatGatewayNatIpCidrBasicDependence12366) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) @@ -41,73 +43,213 @@ func TestAccAlicloudVPCNatIpCidr_basic0(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccConfig(map[string]interface{}{ - "nat_ip_cidr": "192.168.0.0/16", - "nat_gateway_id": "${alicloud_nat_gateway.default.id}", - "nat_ip_cidr_description": "${var.name}", - "nat_ip_cidr_name": "${var.name}", + "nat_ip_cidr": "10.0.12.0/24", + "nat_ip_cidr_name": name, + "nat_gateway_id": "${alicloud_nat_gateway.NATGateway.id}", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "nat_ip_cidr": "192.168.0.0/16", - "nat_gateway_id": CHECKSET, - "nat_ip_cidr_description": name, - "nat_ip_cidr_name": name, + "nat_ip_cidr": "10.0.12.0/24", + "nat_ip_cidr_name": name, + "nat_gateway_id": CHECKSET, }), ), }, { Config: testAccConfig(map[string]interface{}{ - "nat_ip_cidr_description": "${var.name}_update", + "nat_ip_cidr_name": name + "_update", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "nat_ip_cidr_description": name + "_update", + "nat_ip_cidr_name": name + "_update", }), ), }, { Config: testAccConfig(map[string]interface{}{ - "nat_ip_cidr_name": "${var.name}_update", + "nat_ip_cidr_description": "test-update", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "nat_ip_cidr_name": name + "_update", + "nat_ip_cidr_description": "test-update", }), ), }, + { + ResourceName: resourceId, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"dry_run"}, + }, + }, + }) +} + +func TestAccAliCloudNatGatewayNatIpCidr_basic12366_twin(t *testing.T) { + var v map[string]interface{} + resourceId := "alicloud_vpc_nat_ip_cidr.default" + ra := resourceAttrInit(resourceId, AliCloudNatGatewayNatIpCidrMap12366) + rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { + return &NATGatewayServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeNatGatewayNatIpCidr") + rac := resourceAttrCheckInit(rc, ra) + testAccCheck := rac.resourceAttrMapUpdateSet() + rand := acctest.RandIntRange(10000, 99999) + name := fmt.Sprintf("tfaccnatgateway%d", rand) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudNatGatewayNatIpCidrBasicDependence12366) + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + IDRefreshName: resourceId, + Providers: testAccProviders, + CheckDestroy: rac.checkResourceDestroy(), + Steps: []resource.TestStep{ { Config: testAccConfig(map[string]interface{}{ - "nat_ip_cidr_description": "${var.name}", - "nat_ip_cidr_name": "${var.name}", + "nat_ip_cidr": "10.0.12.0/24", + "nat_ip_cidr_description": "tf-test-natipcidr", + "dry_run": "false", + "nat_ip_cidr_name": name, + "nat_gateway_id": "${alicloud_nat_gateway.NATGateway.id}", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "nat_ip_cidr_description": name, + "nat_ip_cidr": "10.0.12.0/24", + "nat_ip_cidr_description": "tf-test-natipcidr", "nat_ip_cidr_name": name, + "nat_gateway_id": CHECKSET, + }), + ), + }, + { + ResourceName: resourceId, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"dry_run"}, + }, + }, + }) +} + +var AliCloudNatGatewayNatIpCidrMap12366 = map[string]string{ + "status": CHECKSET, + "create_time": CHECKSET, +} + +func AliCloudNatGatewayNatIpCidrBasicDependence12366(name string) string { + return fmt.Sprintf(` +variable "name" { + default = "%s" +} + +data "alicloud_zones" "default" { + available_resource_creation = "VSwitch" +} + +resource "alicloud_vpc" "vpc" { + cidr_block = "172.16.0.0/12" + vpc_name = "tf-natipcidr-test-vpc" +} + +resource "alicloud_vswitch" "VSwitch" { + vpc_id = alicloud_vpc.vpc.id + zone_id = data.alicloud_zones.default.zones.0.id + cidr_block = "172.16.0.0/24" + vswitch_name = "tf-test-natipcidr-vsw" +} + +resource "alicloud_nat_gateway" "NATGateway" { + nat_gateway_name = "tf-test-natipcidr" + nat_type = "Enhanced" + vpc_id = alicloud_vpc.vpc.id + vswitch_id = alicloud_vswitch.VSwitch.id + network_type = "intranet" + payment_type = "PayAsYouGo" +} + + +`, name) +} + +// Test NatGateway NatIpCidr. <<< Resource test cases, automatically generated. + +func TestAccAliCloudVPCNatIpCidr_basic0(t *testing.T) { + var v map[string]interface{} + resourceId := "alicloud_vpc_nat_ip_cidr.default" + ra := resourceAttrInit(resourceId, AliCloudVPCNatIpCidrMap0) + rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { + return &NATGatewayServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeNatGatewayNatIpCidr") + rac := resourceAttrCheckInit(rc, ra) + testAccCheck := rac.resourceAttrMapUpdateSet() + rand := acctest.RandIntRange(10000, 99999) + name := fmt.Sprintf("tf-testacc%svpcnatipcidr%d", defaultRegionToTest, rand) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudVPCNatIpCidrBasicDependence0) + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + IDRefreshName: resourceId, + Providers: testAccProviders, + CheckDestroy: rac.checkResourceDestroy(), + Steps: []resource.TestStep{ + { + Config: testAccConfig(map[string]interface{}{ + "nat_ip_cidr": "192.168.0.0/16", + "nat_gateway_id": "${alicloud_nat_gateway.default.id}", + "nat_ip_cidr_name": name, + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "nat_ip_cidr": "192.168.0.0/16", + "nat_gateway_id": CHECKSET, + "nat_ip_cidr_name": name, + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "nat_ip_cidr_description": name, + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "nat_ip_cidr_description": name, + }), + ), + }, + { + Config: testAccConfig(map[string]interface{}{ + "nat_ip_cidr_name": name + "_update", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "nat_ip_cidr_name": name + "_update", }), ), }, { - ResourceName: resourceId, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceId, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"dry_run"}, }, }, }) } -func TestAccAlicloudVPCNatIpCidr_basic1(t *testing.T) { +func TestAccAliCloudVPCNatIpCidr_basic0_twin(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_vpc_nat_ip_cidr.default" - ra := resourceAttrInit(resourceId, AlicloudVPCNatIpCidrMap0) + ra := resourceAttrInit(resourceId, AliCloudVPCNatIpCidrMap0) rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { - return &VpcService{testAccProvider.Meta().(*connectivity.AliyunClient)} - }, "DescribeVpcNatIpCidr") + return &NATGatewayServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} + }, "DescribeNatGatewayNatIpCidr") rac := resourceAttrCheckInit(rc, ra) testAccCheck := rac.resourceAttrMapUpdateSet() rand := acctest.RandIntRange(10000, 99999) name := fmt.Sprintf("tf-testacc%svpcnatipcidr%d", defaultRegionToTest, rand) - testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudVPCNatIpCidrBasicDependence0) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudVPCNatIpCidrBasicDependence0) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) @@ -120,17 +262,16 @@ func TestAccAlicloudVPCNatIpCidr_basic1(t *testing.T) { Config: testAccConfig(map[string]interface{}{ "nat_ip_cidr": "192.168.0.0/16", "nat_gateway_id": "${alicloud_nat_gateway.default.id}", - "nat_ip_cidr_description": "${var.name}", - "nat_ip_cidr_name": "${var.name}", + "nat_ip_cidr_name": name, + "nat_ip_cidr_description": name, "dry_run": "false", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ "nat_ip_cidr": "192.168.0.0/16", "nat_gateway_id": CHECKSET, - "nat_ip_cidr_description": name, "nat_ip_cidr_name": name, - "dry_run": "false", + "nat_ip_cidr_description": name, }), ), }, @@ -144,47 +285,46 @@ func TestAccAlicloudVPCNatIpCidr_basic1(t *testing.T) { }) } -var AlicloudVPCNatIpCidrMap0 = map[string]string{ - "nat_gateway_id": CHECKSET, - "nat_ip_cidr": CHECKSET, +var AliCloudVPCNatIpCidrMap0 = map[string]string{ + "status": CHECKSET, + "create_time": CHECKSET, } -func AlicloudVPCNatIpCidrBasicDependence0(name string) string { +func AliCloudVPCNatIpCidrBasicDependence0(name string) string { return fmt.Sprintf(` variable "name" { default = "%s" } data "alicloud_zones" "default" { - available_resource_creation= "VSwitch" + available_resource_creation = "VSwitch" } resource "alicloud_vpc" "default" { - vpc_name = "${var.name}" - cidr_block = "172.16.0.0/12" + vpc_name = var.name + cidr_block = "172.16.0.0/12" } resource "alicloud_vswitch" "default" { - vpc_id = alicloud_vpc.default.id - cidr_block = "172.16.0.0/21" - zone_id = data.alicloud_zones.default.zones.0.id - vswitch_name = var.name + vpc_id = alicloud_vpc.default.id + cidr_block = "172.16.0.0/21" + zone_id = data.alicloud_zones.default.zones.0.id + vswitch_name = var.name } resource "alicloud_nat_gateway" "default" { - vpc_id = alicloud_vpc.default.id - internet_charge_type = "PayByLcu" - nat_gateway_name = var.name - description = "${var.name}_description" - nat_type = "Enhanced" - vswitch_id = alicloud_vswitch.default.id - network_type = "intranet" + vpc_id = alicloud_vpc.default.id + internet_charge_type = "PayByLcu" + nat_gateway_name = var.name + nat_type = "Enhanced" + vswitch_id = alicloud_vswitch.default.id + network_type = "intranet" } `, name) } // lintignore: R001 -func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { +func TestUnitAliCloudVPCNatIpCidr(t *testing.T) { p := Provider().(*schema.Provider).ResourcesMap d, _ := schema.InternalMap(p["alicloud_vpc_nat_ip_cidr"].Schema).Data(nil, nil) dCreate, _ := schema.InternalMap(p["alicloud_vpc_nat_ip_cidr"].Schema).Data(nil, nil) @@ -275,7 +415,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { StatusCode: tea.Int(400), } }) - err := resourceAlicloudVpcNatIpCidrCreate(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrCreate(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -292,7 +432,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["CreateNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrCreate(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrCreate(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -309,7 +449,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["CreateNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrCreate(dCreate, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrCreate(dCreate, rawClient) patches.Reset() assert.Nil(t, err) }) @@ -327,7 +467,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["CreateNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrCreate(dCreate, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrCreate(dCreate, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -345,11 +485,11 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } }) - err := resourceAlicloudVpcNatIpCidrUpdate(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrUpdate(d, rawClient) patches.Reset() assert.NotNil(t, err) }) - t.Run("UpdateVpcNatIpCidrsAbnormal", func(t *testing.T) { + t.Run("UpdateNatGatewayNatIpCidrsAbnormal", func(t *testing.T) { diff := terraform.NewInstanceDiff() for _, key := range []string{"nat_ip_cidr_description", "nat_ip_cidr_name", "dry_run"} { switch p["alicloud_vpc_nat_ip_cidr"].Schema[key].Type { @@ -377,11 +517,11 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["UpdateNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrUpdate(resourceData1, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrUpdate(resourceData1, rawClient) patches.Reset() assert.NotNil(t, err) }) - t.Run("UpdateVpcNatIpCidrsNormal", func(t *testing.T) { + t.Run("UpdateNatGatewayNatIpCidrsNormal", func(t *testing.T) { diff := terraform.NewInstanceDiff() for _, key := range []string{"nat_ip_cidr_description", "nat_ip_cidr_name", "dry_run"} { switch p["alicloud_vpc_nat_ip_cidr"].Schema[key].Type { @@ -409,7 +549,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["UpdateNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrUpdate(resourceData1, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrUpdate(resourceData1, rawClient) patches.Reset() assert.Nil(t, err) }) @@ -424,7 +564,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { StatusCode: tea.Int(400), } }) - err := resourceAlicloudVpcNatIpCidrDelete(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrDelete(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -441,7 +581,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["DeleteNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrDelete(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrDelete(d, rawClient) patches.Reset() assert.NotNil(t, err) }) @@ -458,7 +598,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["DeleteNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrDelete(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrDelete(d, rawClient) patches.Reset() assert.Nil(t, err) }) @@ -475,7 +615,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["ReadNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrRead(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrRead(d, rawClient) patcheDorequest.Reset() assert.Nil(t, err) }) @@ -491,7 +631,7 @@ func TestUnitAlicloudVPCNatIpCidr(t *testing.T) { } return responseMock["ReadNormal"]("") }) - err := resourceAlicloudVpcNatIpCidrRead(d, rawClient) + err := resourceAliCloudNatGatewayNatIpCidrRead(d, rawClient) patcheDorequest.Reset() assert.NotNil(t, err) }) diff --git a/alicloud/service_alicloud_api_gateway_v2.go b/alicloud/service_alicloud_api_gateway_v2.go index c3dd0b3c55ff..1c1233e84273 100644 --- a/alicloud/service_alicloud_api_gateway_v2.go +++ b/alicloud/service_alicloud_api_gateway_v2.go @@ -320,6 +320,73 @@ func (s *ApiGatewayServiceV2) DescribeApiGatewayAclEntryAttachmentAttribute(id s return object, WrapErrorf(NotFoundErr("AclEntryAttachment", id), NotFoundWithResponse, response) } +func (s *ApiGatewayServiceV2) DescribeApiGatewayGroupPluginAttachment(id string) (object map[string]interface{}, err error) { + parts, err2 := ParseResourceId(id, 3) + if err2 != nil { + return object, WrapError(err2) + } + + client := s.client + var response map[string]interface{} + + action := "DescribePluginsByGroup" + request := make(map[string]interface{}) + request["GroupId"] = parts[0] + request["StageName"] = parts[2] + request["PageSize"] = 100 + wait := incrementalWait(3*time.Second, 3*time.Second) + err = resource.Retry(client.GetRetryTimeout(1*time.Minute), func() *resource.RetryError { + response, err = client.RpcPost("CloudAPI", "2016-07-14", action, nil, request, false) + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + addDebug(action, response, request) + return nil + }) + + if err != nil { + if IsExpectedErrors(err, []string{"InvokeDescribePluginsByGroupApiFail"}) { + return object, WrapErrorf(NotFoundErr("GroupPluginAttachment", id), NotFoundMsg, response) + } + addDebug(action, response, request) + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + v, err := jsonpath.Get("$.Plugins.PluginAttribute[*]", response) + if err != nil { + return object, WrapErrorf(err, DefaultErrorMsg, "$.Plugins.PluginAttribute[*]", response) + } + + if len(v.([]interface{})) == 0 { + return object, WrapErrorf(NotFoundErr("GroupPluginAttachment", id), NotFoundMsg, response) + } + + plugins := v.([]interface{}) + pluginId := parts[1] + + var foundPlugin map[string]interface{} + + for _, plugin := range plugins { + pluginMap := plugin.(map[string]interface{}) + if pluginMap["PluginId"].(string) == pluginId { + foundPlugin = pluginMap + foundPlugin["GroupId"] = parts[0] + foundPlugin["StageName"] = parts[2] + break + } + } + + if foundPlugin == nil { + return object, WrapErrorf(NotFoundErr("GroupPluginAttachment", id), NotFoundMsg, response) + } + + return foundPlugin, nil +} + func (s *ApiGatewayServiceV2) DescribeApiGatewayInstanceAclAttachmentAttribute(id string) (object map[string]interface{}, err error) { parts, err := ParseResourceIds(id) if err != nil { diff --git a/alicloud/service_alicloud_esa_v2.go b/alicloud/service_alicloud_esa_v2.go index d2f8558ce678..43e874facf1f 100644 --- a/alicloud/service_alicloud_esa_v2.go +++ b/alicloud/service_alicloud_esa_v2.go @@ -162,6 +162,40 @@ func (s *EsaServiceV2) DescribeSiteGetCacheTag(id string) (object map[string]int return response, nil } +func (s *EsaServiceV2) DescribeSiteGetClientCertificateHostnames(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + request = make(map[string]interface{}) + query = make(map[string]interface{}) + query["SiteId"] = id + + action := "GetClientCertificateHostnames" + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcGet("ESA", "2024-09-10", action, query, request) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + if IsExpectedErrors(err, []string{"SiteNotFound", "101", "32"}) { + return object, WrapErrorf(NotFoundErr("Site", id), NotFoundMsg, response) + } + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + return response, nil +} func (s *EsaServiceV2) DescribeSiteGetIPv6(id string) (object map[string]interface{}, err error) { client := s.client var request map[string]interface{} @@ -230,6 +264,40 @@ func (s *EsaServiceV2) DescribeSiteGetCacheReserve(id string) (object map[string return response, nil } +func (s *EsaServiceV2) DescribeSiteDescribeHttpDDoSAttackIntelligentProtection(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["SiteId"] = id + + action := "DescribeHttpDDoSAttackIntelligentProtection" + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + if IsExpectedErrors(err, []string{"SiteNotFound", "32", "101", "SiteIdDDoSVersionCheckFailed"}) { + return object, WrapErrorf(NotFoundErr("Site", id), NotFoundMsg, response) + } + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + return response, nil +} func (s *EsaServiceV2) DescribeSiteGetTieredCache(id string) (object map[string]interface{}, err error) { client := s.client var request map[string]interface{} @@ -468,6 +536,74 @@ func (s *EsaServiceV2) DescribeSiteGetSitePause(id string) (object map[string]in return response, nil } +func (s *EsaServiceV2) DescribeSiteDescribeHttpDDoSAttackProtection(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["SiteId"] = id + + action := "DescribeHttpDDoSAttackProtection" + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + if IsExpectedErrors(err, []string{"SiteNotFound", "32", "101", "SiteIdDDoSVersionCheckFailed"}) { + return object, WrapErrorf(NotFoundErr("Site", id), NotFoundMsg, response) + } + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + return response, nil +} +func (s *EsaServiceV2) DescribeSiteGetPerformanceDataCollection(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["SiteId"] = id + + action := "GetPerformanceDataCollection" + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcPost("ESA", "2024-09-10", action, query, request, true) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + if IsExpectedErrors(err, []string{"SiteNotFound", "101", "32"}) { + return object, WrapErrorf(NotFoundErr("Site", id), NotFoundMsg, response) + } + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + return response, nil +} func (s *EsaServiceV2) EsaSiteStateRefreshFunc(id string, field string, failStates []string) resource.StateRefreshFunc { return s.EsaSiteStateRefreshFuncWithApi(id, field, failStates, s.DescribeEsaSite) diff --git a/alicloud/service_alicloud_nat_gateway_v2.go b/alicloud/service_alicloud_nat_gateway_v2.go index 51e1a1873475..3ba57a3918b0 100644 --- a/alicloud/service_alicloud_nat_gateway_v2.go +++ b/alicloud/service_alicloud_nat_gateway_v2.go @@ -95,3 +95,88 @@ func (s *NATGatewayServiceV2) NATGatewaySnatEntryStateRefreshFunc(id string, fie } // DescribeNATGatewaySnatEntry >>> Encapsulated. + +// DescribeNatGatewayNatIpCidr <<< Encapsulated get interface for NatGateway NatIpCidr. + +func (s *NATGatewayServiceV2) DescribeNatGatewayNatIpCidr(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + parts := strings.Split(id, ":") + if len(parts) != 2 { + err = WrapError(fmt.Errorf("invalid Resource Id %s. Expected parts' length %d, got %d", id, 2, len(parts))) + return nil, err + } + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["NatGatewayId"] = parts[0] + request["NatIpCidr"] = parts[1] + request["RegionId"] = client.RegionId + action := "ListNatIpCidrs" + request["ClientToken"] = buildClientToken(action) + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcPost("Vpc", "2016-04-28", action, query, request, true) + request["ClientToken"] = buildClientToken(action) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + v, err := jsonpath.Get("$.NatIpCidrs[*]", response) + if err != nil { + return object, WrapErrorf(err, FailedGetAttributeMsg, id, "$.NatIpCidrs[*]", response) + } + + if len(v.([]interface{})) == 0 { + return object, WrapErrorf(NotFoundErr("NatIpCidr", id), NotFoundMsg, response) + } + + return v.([]interface{})[0].(map[string]interface{}), nil +} + +func (s *NATGatewayServiceV2) NatGatewayNatIpCidrStateRefreshFunc(id string, field string, failStates []string) resource.StateRefreshFunc { + return s.NatGatewayNatIpCidrStateRefreshFuncWithApi(id, field, failStates, s.DescribeNatGatewayNatIpCidr) +} + +func (s *NATGatewayServiceV2) NatGatewayNatIpCidrStateRefreshFuncWithApi(id string, field string, failStates []string, call func(id string) (map[string]interface{}, error)) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + object, err := call(id) + if err != nil { + if NotFoundError(err) { + return object, "", nil + } + return nil, "", WrapError(err) + } + v, err := jsonpath.Get(field, object) + currentStatus := fmt.Sprint(v) + + if strings.HasPrefix(field, "#") { + v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object) + if v != nil { + currentStatus = "#CHECKSET" + } + } + + for _, failState := range failStates { + if currentStatus == failState { + return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus)) + } + } + return object, currentStatus, nil + } +} + +// DescribeNatGatewayNatIpCidr >>> Encapsulated. diff --git a/alicloud/service_alicloud_nlb_v2.go b/alicloud/service_alicloud_nlb_v2.go index 457c42b4a6da..21dd9a56dc06 100644 --- a/alicloud/service_alicloud_nlb_v2.go +++ b/alicloud/service_alicloud_nlb_v2.go @@ -986,3 +986,75 @@ func (s *NlbServiceV2) NlbLoadBalancerZoneShiftedAttachmentStateRefreshFunc(id s } // DescribeNlbLoadBalancerZoneShiftedAttachment >>> Encapsulated. +// DescribeNlbHdMonitorRegionConfig <<< Encapsulated get interface for Nlb HdMonitorRegionConfig. + +func (s *NlbServiceV2) DescribeNlbHdMonitorRegionConfig(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + request = make(map[string]interface{}) + query = make(map[string]interface{}) + request["RegionId"] = id + request["RegionId"] = client.RegionId + action := "DescribeHdMonitorRegionConfig" + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcPost("Nlb", "2022-04-30", action, query, request, true) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + currentStatus := response["LogProject"] + if fmt.Sprint(currentStatus) == "" { + return object, WrapErrorf(NotFoundErr("HdMonitorRegionConfig", id), NotFoundMsg, response) + } + + return response, nil +} + +func (s *NlbServiceV2) NlbHdMonitorRegionConfigStateRefreshFunc(id string, field string, failStates []string) resource.StateRefreshFunc { + return s.NlbHdMonitorRegionConfigStateRefreshFuncWithApi(id, field, failStates, s.DescribeNlbHdMonitorRegionConfig) +} + +func (s *NlbServiceV2) NlbHdMonitorRegionConfigStateRefreshFuncWithApi(id string, field string, failStates []string, call func(id string) (map[string]interface{}, error)) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + object, err := call(id) + if err != nil { + if NotFoundError(err) { + return object, "", nil + } + return nil, "", WrapError(err) + } + v, err := jsonpath.Get(field, object) + currentStatus := fmt.Sprint(v) + + if strings.HasPrefix(field, "#") { + v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object) + if v != nil { + currentStatus = "#CHECKSET" + } + } + + for _, failState := range failStates { + if currentStatus == failState { + return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus)) + } + } + return object, currentStatus, nil + } +} + +// DescribeNlbHdMonitorRegionConfig >>> Encapsulated. diff --git a/alicloud/service_alicloud_rds_v2.go b/alicloud/service_alicloud_rds_v2.go index 2157cb46ea51..518272b17a13 100644 --- a/alicloud/service_alicloud_rds_v2.go +++ b/alicloud/service_alicloud_rds_v2.go @@ -520,3 +520,85 @@ func (s *RdsServiceV2) RdsAccountStateRefreshFuncWithApi(id string, field string } // DescribeRdsAccount >>> Encapsulated. +// DescribeRdsBackup <<< Encapsulated get interface for Rds Backup. + +func (s *RdsServiceV2) DescribeRdsBackup(id string) (object map[string]interface{}, err error) { + client := s.client + var request map[string]interface{} + var response map[string]interface{} + var query map[string]interface{} + request = make(map[string]interface{}) + query = make(map[string]interface{}) + parts, err := ParseResourceId(id, 2) + if err != nil { + err = WrapError(err) + return + } + request["DBInstanceId"] = parts[0] + request["BackupId"] = parts[1] + request["RegionId"] = client.RegionId + action := "DescribeBackups" + + wait := incrementalWait(3*time.Second, 5*time.Second) + err = resource.Retry(1*time.Minute, func() *resource.RetryError { + response, err = client.RpcPost("Rds", "2014-08-15", action, query, request, true) + + if err != nil { + if NeedRetry(err) { + wait() + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + addDebug(action, response, request) + if err != nil { + return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) + } + + v, err := jsonpath.Get("$.Items.Backup[*]", response) + if err != nil { + return object, WrapErrorf(err, FailedGetAttributeMsg, id, "$.Items.Backup[*]", response) + } + + if len(v.([]interface{})) == 0 { + return object, WrapErrorf(NotFoundErr("Backup", id), NotFoundMsg, response) + } + + return v.([]interface{})[0].(map[string]interface{}), nil +} + +func (s *RdsServiceV2) RdsBackupStateRefreshFunc(id string, field string, failStates []string) resource.StateRefreshFunc { + return s.RdsBackupStateRefreshFuncWithApi(id, field, failStates, s.DescribeRdsBackup) +} + +func (s *RdsServiceV2) RdsBackupStateRefreshFuncWithApi(id string, field string, failStates []string, call func(id string) (map[string]interface{}, error)) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + object, err := call(id) + if err != nil { + if NotFoundError(err) { + return object, "", nil + } + return nil, "", WrapError(err) + } + v, err := jsonpath.Get(field, object) + currentStatus := fmt.Sprint(v) + + if strings.HasPrefix(field, "#") { + v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object) + if v != nil { + currentStatus = "#CHECKSET" + } + } + + for _, failState := range failStates { + if currentStatus == failState { + return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus)) + } + } + return object, currentStatus, nil + } +} + +// DescribeRdsBackup >>> Encapsulated. diff --git a/go.mod b/go.mod index 759d01c9dba3..e807aaca156f 100644 --- a/go.mod +++ b/go.mod @@ -43,6 +43,9 @@ require ( github.com/alibabacloud-go/sts-20150401/v2 v2.0.2 github.com/alibabacloud-go/tea-utils/v2 v2.0.7 github.com/blues/jsonata-go v1.5.4 + github.com/hashicorp/errwrap v1.1.0 + github.com/hashicorp/go-cleanhttp v0.5.2 + github.com/keybase/go-crypto v0.0.0-20190416182011-b785b22cc757 github.com/samber/lo v1.49.1 github.com/tidwall/sjson v1.2.5 golang.org/x/tools v0.38.0 @@ -108,7 +111,6 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v23.5.26+incompatible // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -118,9 +120,7 @@ require ( github.com/googleapis/gax-go/v2 v2.12.3 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grafana/regexp v0.0.0-20221005093135-b4c2bcb0a4b6 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.3 // indirect github.com/hashicorp/go-hclog v1.6.2 // indirect github.com/hashicorp/go-multierror v1.0.0 // indirect @@ -141,7 +141,6 @@ require ( github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/keybase/go-crypto v0.0.0-20190416182011-b785b22cc757 // indirect github.com/klauspost/compress v1.17.8 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/scripts/local-ci-check.sh b/scripts/local-ci-check.sh index 437ed44a8376..70dec5e3622a 100755 --- a/scripts/local-ci-check.sh +++ b/scripts/local-ci-check.sh @@ -27,6 +27,7 @@ SKIP_ERRCHECK=true # Default: skip errcheck locally (CI still runs it) SKIP_MARKDOWN_LINT=true # Default: skip markdown lint locally (CI still runs it) SKIP_MARKDOWN_LINK_CHECK=true # Default: skip markdown link check locally (CI still runs it) SKIP_EXAMPLE_TEST=false # Default: run example tests (use --skip-example-test to disable) +SKIP_RESOURCE_TEST=false # Default: run resource integration tests (use --skip-resource-test to disable) STRICT_MODE=false # Strict mode checks ALL docs like CI does while [[ $# -gt 0 ]]; do @@ -59,11 +60,16 @@ while [[ $# -gt 0 ]]; do SKIP_EXAMPLE_TEST=true shift ;; + --skip-resource-test) + SKIP_RESOURCE_TEST=true + shift + ;; --quick) SKIP_BUILD=true SKIP_TEST=true SKIP_ERRCHECK=true SKIP_EXAMPLE_TEST=true + SKIP_RESOURCE_TEST=true shift ;; --strict) @@ -81,7 +87,8 @@ while [[ $# -gt 0 ]]; do echo " --run-markdown-lint Run markdown lint (default: skipped locally)" echo " --run-markdown-link-check Run markdown link check (default: skipped locally)" echo " --skip-example-test Skip example tests (default: enabled)" - echo " --quick Skip build, tests, errcheck, and example tests (faster checks)" + echo " --skip-resource-test Skip resource integration tests (default: enabled)" + echo " --quick Skip build, tests, errcheck, example tests, and resource tests (faster checks)" echo " --strict Check ALL docs (like CI), not just changed files" echo " -h, --help Show this help message" echo "" @@ -712,6 +719,89 @@ else fi fi +# ============================================================================ +# 7. Resource Integration Tests +# ============================================================================ + +echo -e "${GREEN}═══════════════════════════════════════════════════════════════${NC}" +echo -e "${GREEN} Part 7: Resource Integration Tests${NC}" +echo -e "${GREEN}═══════════════════════════════════════════════════════════════${NC}" +echo + +CHANGED_RESOURCE_FILES=$(echo "$CHANGED_FILES" | grep -E "^alicloud/(resource|data_source)_alicloud_.*\.go$" | grep -v "_test\.go$" || true) + +if [ -z "$CHANGED_RESOURCE_FILES" ]; then + echo -e "${BLUE}▶ No resource or data source changes detected${NC}" + echo -e "${GREEN}✓ SKIPPED: Resource Integration Tests (no resource changes)${NC}" + echo +elif [ "$SKIP_RESOURCE_TEST" = true ]; then + echo -e "${YELLOW}⚠ Skipping Resource Integration Tests (use default to enable)${NC}" + echo + echo -e "${BLUE}Changed resources detected:${NC}" + for file in $CHANGED_RESOURCE_FILES; do + resource_name=$(basename "$file" .go | sed -E 's/^(resource|data_source)_//') + echo -e " - ${resource_name}" + done + echo + echo -e "${BLUE}💡 To enable resource integration tests, run:${NC}" + echo -e " ${GREEN}make ci-check${NC} (default behavior, requires credentials)" + echo +else + if [ -z "$ALICLOUD_ACCESS_KEY" ] || [ -z "$ALICLOUD_SECRET_KEY" ]; then + echo -e "${RED}✗ Cannot run resource integration tests: AliCloud credentials not set${NC}" + echo + echo -e "${YELLOW}Please set the following environment variables:${NC}" + echo -e " ${GREEN}export ALICLOUD_ACCESS_KEY=your_access_key${NC}" + echo -e " ${GREEN}export ALICLOUD_SECRET_KEY=your_secret_key${NC}" + echo -e " ${GREEN}export ALICLOUD_REGION=cn-hangzhou${NC} ${YELLOW}# optional${NC}" + echo + echo -e "${BLUE}💡 To skip resource integration tests:${NC}" + echo -e " ${GREEN}make ci-check SKIP_TEST=1${NC}" + echo + FAILED_CHECKS+=("Resource Integration Tests (credentials not set)") + else + RESOURCE_NAMES="" + for file in $CHANGED_RESOURCE_FILES; do + resource_name=$(basename "$file" .go | sed -E 's/^(resource|data_source)_//') + RESOURCE_NAMES="${RESOURCE_NAMES}${resource_name} " + done + RESOURCE_NAMES=$(echo "$RESOURCE_NAMES" | tr ' ' '\n' | sort -u | tr '\n' ' ') + + RESOURCE_COUNT=$(echo "$RESOURCE_NAMES" | wc -w | tr -d ' ') + echo -e "${BLUE}▶ Found ${RESOURCE_COUNT} changed resource(s) to test:${NC}" + for resource in $RESOURCE_NAMES; do + echo -e " - ${resource}" + done + echo + echo -e "${YELLOW}⚠ WARNING: Resource integration tests will create REAL resources in your AliCloud account!${NC}" + echo + + RESOURCE_TEST_FAILED=false + for resource in $RESOURCE_NAMES; do + echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + echo -e "${BLUE}▶ Running integration tests for: ${resource}${NC}" + echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + + if make -C "$PROJECT_ROOT" test-resource-debug RESOURCE="${resource}"; then + echo -e "${GREEN}✓ PASSED: Resource Integration Test (${resource})${NC}" + PASSED_CHECKS+=("Resource Integration Test (${resource})") + else + echo -e "${RED}✗ FAILED: Resource Integration Test (${resource})${NC}" + FAILED_CHECKS+=("Resource Integration Test (${resource})") + RESOURCE_TEST_FAILED=true + fi + echo + done + + if [ "$RESOURCE_TEST_FAILED" = true ]; then + echo -e "${RED}✗ Some resource integration tests failed${NC}" + else + echo -e "${GREEN}✓ All resource integration tests passed${NC}" + fi + echo + fi +fi + # ============================================================================ # Summary # ============================================================================ diff --git a/website/docs/r/api_gateway_group_plugin_attachment.html.markdown b/website/docs/r/api_gateway_group_plugin_attachment.html.markdown new file mode 100644 index 000000000000..2fb6c5f9a473 --- /dev/null +++ b/website/docs/r/api_gateway_group_plugin_attachment.html.markdown @@ -0,0 +1,73 @@ +--- +subcategory: "Api Gateway" +layout: "alicloud" +page_title: "Alicloud: alicloud_api_gateway_plugin_attachment" +sidebar_current: "docs-alicloud-resource-api-gateway-plugin-attachment" +description: |- + Provides a Alicloud Api Gateway Plugin Attachment Resource. +--- + +# alicloud_api_gateway_group_plugin_attachment + +Provides a plugin attachment resource.It is used for attaching a specific plugin to an api group. + +For information about Api Gateway Plugin attachment and how to use it, see [Attach Plugin to specified API GROUP](https://www.alibabacloud.com/help/en/api-gateway/traditional-api-gateway/developer-reference/api-cloudapi-2016-07-14-attachgroupplugin) + +-> **NOTE:** Available since v1.273.0 + +-> **NOTE:** Terraform will auto build plugin attachment while it uses `alicloud_api_gateway_group_plugin_attachment` to build. + +## Example Usage + +Basic Usage + + +```terraform +provider "alicloud" { + region = "cn-beijing" +} + +variable "name" { + default = "terraform_example" +} +resource "alicloud_api_gateway_group" "example" { + name = var.name + description = var.name +} + +resource "alicloud_api_gateway_plugin" "example" { + description = "tf_example" + plugin_name = "tf_example" + plugin_data = jsonencode({ "allowOrigins" : "api.foo.com", "allowMethods" : "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH", "allowHeaders" : "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid", "exposeHeaders" : "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message", "maxAge" : 172800, "allowCredentials" : true }) + plugin_type = "cors" +} + +resource "alicloud_api_gateway_group_plugin_attachment" "example" { + group_id = alicloud_api_gateway_group.example.id + plugin_id = alicloud_api_gateway_plugin.example.id + stage_name = "RELEASE" +} +``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_api_gateway_plugin_attachment&spm=docs.r.api_gateway_plugin_attachment.example&intl_lang=EN_US) + +## Argument Reference + +The following arguments are supported: +* `group_id` - (Required, ForceNew) The group that plugin attaches to. +* `plugin_id` - (Required, ForceNew) The plugin that attaches to the group. +* `stage_name` - (Required, ForceNew) Stage that the plugin attaches to. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The resource ID of the group plugin attachment. The value formats as `<group_id>:<plugin_id>:<stage_name>`. + +## Import + +Api Gateway group plugin attachment a can be imported using the id, e.g. + +```shell +$ terraform import alicloud_api_gateway_group_plugin_attachment.example <group_id>:<plugin_id>:<stage_name> +``` \ No newline at end of file diff --git a/website/docs/r/dms_enterprise_instance.html.markdown b/website/docs/r/dms_enterprise_instance.html.markdown index 6063686c0a38..fa657e88af25 100644 --- a/website/docs/r/dms_enterprise_instance.html.markdown +++ b/website/docs/r/dms_enterprise_instance.html.markdown @@ -129,6 +129,10 @@ The following arguments are supported: * `port` - (Required, ForceNew) Access port of the target database. * `database_user` - (Required) Database access account. * `database_password` - (Required) Database access password. +* `sell_trust` -(Required) Whether to enable the security hosting feature for the database instance. Possible values: `true`, `false`. + + ~>**NOTE:** The `database_user` will be encrypted if `sell_trust` set to `false`. + * `instance_alias` - It has been deprecated from provider version 1.100.0 and 'instance_name' instead. * `instance_name` - (Optional, Available since v1.100.0) Instance name, to help users quickly distinguish positioning. * `dba_uid` - (Required, ForceNew) The DBA of the instance is passed into the Alibaba Cloud uid of the DBA. diff --git a/website/docs/r/ecs_network_interface.html.markdown b/website/docs/r/ecs_network_interface.html.markdown index 158aa4c604e1..ee9015467f48 100644 --- a/website/docs/r/ecs_network_interface.html.markdown +++ b/website/docs/r/ecs_network_interface.html.markdown @@ -49,8 +49,8 @@ resource "alicloud_vswitch" "default" { } resource "alicloud_security_group" "default" { - name = var.name - vpc_id = alicloud_vpc.default.id + security_group_name = var.name + vpc_id = alicloud_vpc.default.id } data "alicloud_resource_manager_resource_groups" "default" { @@ -94,6 +94,7 @@ The following arguments are supported: * `instance_type` - (Optional, ForceNew, Available since v1.223.0) The type of the ENI. Default value: `Secondary`. Valid values: `Secondary`, `Trunk`. * `network_interface_traffic_mode` - (Optional, ForceNew, Available since v1.223.0) The communication mode of the ENI. Default value: `Standard`. Valid values: `Standard`, `HighPerformance`. * `source_dest_check` - (Optional, Bool, Available since v1.252.0) Indicates whether the source and destination IP address check feature is enabled. To improve network security, enable this feature. Default value: `false`. Valid values: `true`, `false`. +* `delete_on_release` - (Optional, Bool) Specifies whether to release the ENI when the associated instance is released. Valid values: `true`, `false`. * `name` - (Optional, Deprecated since v1.123.1) Field `name` has been deprecated from provider version 1.123.1. New field `network_interface_name` instead * `private_ip` - (Optional, ForceNew, Deprecated since v1.123.1) Field `private_ip` has been deprecated from provider version 1.123.1. New field `primary_ip_address` instead * `private_ips` - (Optional, List, Deprecated since v1.123.1) Field `private_ips` has been deprecated from provider version 1.123.1. New field `private_ip_addresses` instead diff --git a/website/docs/r/ehpc_cluster.html.markdown b/website/docs/r/ehpc_cluster.html.markdown index fabae081c4dd..1d709b528f9f 100644 --- a/website/docs/r/ehpc_cluster.html.markdown +++ b/website/docs/r/ehpc_cluster.html.markdown @@ -21,12 +21,6 @@ For information about Ehpc Cluster and how to use it, see [What is Cluster](http Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_ehpc_cluster&exampleId=1b7ca10e-5127-a55b-5b13-3c1843903f664ae1bd93&activeTab=example&spm=docs.r.ehpc_cluster.0.1b7ca10e51&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform variable "name" { default = "tf-example" diff --git a/website/docs/r/elasticsearch_instance.html.markdown b/website/docs/r/elasticsearch_instance.html.markdown index 50a8506be024..d0802c540d35 100644 --- a/website/docs/r/elasticsearch_instance.html.markdown +++ b/website/docs/r/elasticsearch_instance.html.markdown @@ -48,7 +48,7 @@ resource "alicloud_elasticsearch_instance" "default" { vswitch_id = alicloud_vswitch.default.id password = "Examplw1234" version = "7.10_with_X-Pack" - instance_charge_type = "PostPaid" + payment_type = "PayAsYouGo" data_node_amount = "2" data_node_spec = "elasticsearch.sn2ne.large" data_node_disk_size = "20" @@ -72,61 +72,84 @@ The following arguments are supported: * `kms_encrypted_password` - (Optional, Available since v1.57.1) An KMS encrypts password used to an instance. If the `password` is filled in, this field will be ignored, but you have to specify one of `password` and `kms_encrypted_password` fields. * `kms_encryption_context` - (Optional, MapString, Available since v1.57.1) An KMS encryption context used to decrypt `kms_encrypted_password` before creating or updating instance with `kms_encrypted_password`. See [Encryption Context](https://www.alibabacloud.com/help/doc-detail/42975.htm). It is valid when `kms_encrypted_password` is set. * `period` - (Optional) The duration that you will buy Elasticsearch instance (in month). It is valid when PaymentType is `Subscription`. Valid values: [1~9], 12, 24, 36. Default to 1. From version 1.69.2, when to modify this value, the resource can renewal a `PrePaid` instance. -* `auto_renew_duration` - (Optional, Int) Renewal Period -* `client_node_configuration` - (Optional, Computed, Set, Available since v1.267.0) Elasticsearch cluster coordination node configuration See [`client_node_configuration`](#client_node_configuration) below. -* `data_node_configuration` - (Optional, Computed, Set, Available since v1.267.0) Elasticsearch data node information See [`data_node_configuration`](#data_node_configuration) below. -* `description` - (Optional, Computed) Instance name -* `enable_kibana_private_network` - (Optional, Computed, Available since v1.87.0) Whether to enable Kibana private network access. - -The meaning of the value is as follows: - - true: On. - - false: does not open. -* `enable_kibana_public_network` - (Optional, Computed, Available since v1.87.0) Does Kibana enable public access -* `enable_public` - (Optional, Computed, Available since v1.87.0) Whether to enable Kibana public network access. - -The meaning of the value is as follows: - - true: On. - - false: does not open. -* `force` - (Optional, Available since v1.267.0) Whether to force changes - --> **NOTE:** This parameter only applies during resource update. If modified in isolation without other property changes, Terraform will not trigger any action. - -* `instance_category` - (Optional, ForceNew, Computed, Available since v1.267.0) Version type. -* `kibana_configuration` - (Optional, Computed, Set, Available since v1.267.0) Elasticsearch Kibana node settings See [`kibana_configuration`](#kibana_configuration) below. -* `kibana_private_security_group_id` - (Optional) Kibana private network security group ID -* `kibana_private_whitelist` - (Optional, Computed, List, Available since v1.87.0) Cluster Kibana node private network access whitelist -* `kibana_whitelist` - (Optional, Computed, List) Kibana private network access whitelist -* `master_configuration` - (Optional, Computed, Set, Available since v1.267.0) Elasticsearch proprietary master node configuration information See [`master_configuration`](#master_configuration) below. -* `order_action_type` - (Optional, Available since v1.267.0) The instance changes the operation type. UPGRADE, UPGRADE. DOWNGRADE, DOWNGRADE. - --> **NOTE:** This parameter only applies during resource update. If modified in isolation without other property changes, Terraform will not trigger any action. - -* `password` - (Optional) The access password of the instance. -* `payment_type` - (Optional, Computed, Available since v1.267.0) The payment method of the instance. Optional values: `prepaid` (subscription) and `postpaid` (pay-as-you-go) -* `private_whitelist` - (Optional, Computed, List) Elasticsearch private network whitelist. (Same as EsIpWhitelist) -* `protocol` - (Optional, Computed, Available since v1.101.0) Access protocol. Optional values: `HTTP` and **HTTPS * *. -* `public_whitelist` - (Optional, Computed, List) Elasticseach public network access whitelist IP list -* `renew_status` - (Optional, Computed) Renewal Status -* `renewal_duration_unit` - (Optional, Computed) Renewal Period Unit -* `resource_group_id` - (Optional, ForceNew, Computed, Available since v1.86.0) Resource group to which the instance belongs -* `setting_config` - (Optional, Computed, Map, Available since v1.125.0) Configuration information -* `tags` - (Optional, Computed, Map, Available since v1.73.0) Collection of tag key-value pairs -* `update_strategy` - (Optional, Available since v1.267.0) The change policy for Elasticsearch. - -The values are as follows: - - blue_green: blue-green change, which can realize seamless switching by running two identical environments (blue environment and green environment) in parallel. - - normal: In-place changes, changes are made directly in the current environment (for example, upgrades, scaling) without additional resources. - - intelligent: intelligent change, the system automatically analyzes the change type and environmental status, and dynamically selects the optimal change method (that is, blue-green change or in-situ change). - --> **NOTE:** This parameter only applies during resource update. If modified in isolation without other property changes, Terraform will not trigger any action. - -* `version` - (Required, ForceNew) Instance version -* `warm_node_configuration` - (Optional, Computed, Set, Available since v1.267.0) Elasticsearch cluster cold data node configuration See [`warm_node_configuration`](#warm_node_configuration) below. -* `zone_count` - (Optional, ForceNew, Computed, Int) The number of zones in the Elasticsearch instance. +* `auto_renew_duration` - (Optional, Int) Number of auto-renewal periods. +* `client_node_configuration` - (Optional, Computed, Set, Available since v1.267.0) Configuration of dedicated coordinating nodes in the Elasticsearch cluster. See [`client_node_configuration`](#client_node_configuration) below. +* `data_node_configuration` - (Optional, Computed, Set, Available since v1.267.0) Elasticsearch data node information. See [`data_node_configuration`](#data_node_configuration) below. +* `description` - (Optional, Computed) Instance name, which supports fuzzy search. For example, searching for all instances containing `abc` may return instances named `abc`, `abcde`, `xyabc`, or `xabcy`. +* `enable_kibana_private_network` - (Optional, Computed, Available since v1.87.0) Indicates whether private network access to Kibana is enabled. Valid values: + - true: Enabled + - false: Disabled +* `enable_kibana_public_network` - (Optional, Computed, Available since v1.87.0) Specifies whether to enable public access to Kibana. Valid values: + - true: Enables public access. + - false: Disables public access. +* `enable_public` - (Optional, Computed, Available since v1.87.0) Specifies whether to enable a public endpoint for the instance. Valid values: + - true: Enables the public endpoint. + - false: Disables the public endpoint. +* `force` - (Optional, Available since v1.267.0) Whether to force a restart: + - true: Yes + - false (default): No. + +-> **NOTE:** This parameter only takes effect when other resource properties are also modified. Changing this parameter alone will not trigger a resource update. + +* `instance_category` - (Optional, ForceNew, Computed, Available since v1.267.0) Edition type: + - x-pack: Creates a commercial edition instance, or a kernel-enhanced edition instance without Indexing Service or OpenStore enabled. + - IS: Creates a kernel-enhanced edition instance with Indexing Service or OpenStore enabled. +* `kibana_configuration` - (Optional, Computed, Set, Available since v1.267.0) The configuration of Elasticsearch Kibana nodes. See [`kibana_configuration`](#kibana_configuration) below. +* `kibana_private_security_group_id` - (Optional) List of security groups. +* `kibana_private_whitelist` - (Optional, Computed, List, Available since v1.87.0) List of IP addresses in the whitelist. This parameter is available when whiteIpGroup is empty and is used to modify the default group's whitelist. +* `kibana_whitelist` - (Optional, Computed, List) The list of IP addresses in the whitelist. This parameter is available when whiteIpGroup is empty and modifies the default group's whitelist. +* `master_configuration` - (Optional, Computed, Set, Available since v1.267.0) Configuration information for Elasticsearch dedicated master nodes. See [`master_configuration`](#master_configuration) below. +* `order_action_type` - (Optional, Available since v1.267.0) Configuration change type. Valid values: + - upgrade (default): Upgrade configuration + - downgrade: Downgrade configuration. + +-> **NOTE:** This parameter only takes effect when other resource properties are also modified. Changing this parameter alone will not trigger a resource update. + +* `password` - (Optional) The access password for the instance. It must be 8 to 32 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (!@#$%^&*()_+-=). +* `payment_type` - (Optional, Computed, Available since v1.267.0) The billing method of the instance. Supported values: + - `PayAsYouGo`: Pay-as-you-go + - `Subscription`: Subscription +* `private_whitelist` - (Optional, Computed, List) The list of IP addresses in the whitelist. This parameter is available when whiteIpGroup is empty and modifies the default group's whitelist. +* `protocol` - (Optional, Computed, Available since v1.101.0) The access protocol. Supported protocols: HTTP and HTTPS. +* `public_whitelist` - (Optional, Computed, List) The IP address whitelist. This parameter is available when whiteIpGroup is empty and is used to modify the default group's whitelist. +* `renew_status` - (Optional, Computed) The renewal status. Valid values: + - AutoRenewal: Auto-renewal. + - ManualRenewal: Manual renewal. + - NotRenewal: No renewal. +* `renewal_duration_unit` - (Optional, Computed) The unit of the auto-renewal period. Valid values: + - M: Month. + - Y: Year. + +-> **NOTE:** This parameter is required when RenewalStatus is set to AutoRenewal. + +* `resource_group_id` - (Optional, ForceNew, Computed, Available since v1.86.0) The ID of the resource group to which the instance belongs. +* `setting_config` - (Optional, Computed, Map, Available since v1.125.0) YML configuration file settings for the instance. +* `tags` - (Optional, Computed, Map, Available since v1.73.0) Instance tag group. +* `update_strategy` - (Optional, Available since v1.267.0) Elasticsearch update strategy (for example, index updates, cluster upgrades, or service deployments). Valid values: + - blue_green: Blue-green deployment, which enables seamless switching by running two identical environments (blue and green) in parallel. + - normal: In-place update, which applies changes directly in the current environment (for example, upgrades or scaling) without requiring additional resources. + - intelligent: Intelligent update, where the system automatically analyzes the update type and environment status to dynamically select the optimal strategy (either blue-green or in-place). + +-> **NOTE:** This parameter only takes effect when other resource properties are also modified. Changing this parameter alone will not trigger a resource update. + +* `version` - (Required, ForceNew) The instance version. Valid values: + - 8.5.1_with_X-Pack + - 7.10_with_X-Pack + - 6.7_with_X-Pack + - 7.7_with_X-Pack + - 6.8_with_X-Pack + - 6.3_with_X-Pack + - 5.6_with_X-Pack + - 5.5.3_with_X-Pack + +-> **NOTE:** The versions listed above might not include all versions supported by Elasticsearch instances. You can call the [GetRegionConfiguration](https://help.aliyun.com/document_detail/254099.html) operation to view the actual supported versions. + +* `warm_node_configuration` - (Optional, Computed, Set, Available since v1.267.0) Cold data node configuration for the Elasticsearch cluster. See [`warm_node_configuration`](#warm_node_configuration) below. +* `zone_count` - (Optional, ForceNew, Computed, Int) The number of zones for the instance. Valid values: 1, 2, and 3. Default value: 1. The following arguments will be discarded. Please use new fields as soon as possible: -* `instance_charge_type` - (Optional, Deprecated since v1.261.0) Valid values are `PrePaid`, `PostPaid`. Default to `PostPaid`. From version 1.69.0, the Elasticsearch cluster allows you to update your instance_charge_ype from `PostPaid` to `PrePaid`, the following attributes are required: `period`. +* `instance_charge_type` - (Optional, Deprecated since v1.261.0) Valid values are `PrePaid`, `PostPaid`. Default to `PostPaid`. From version 1.69.0, the Elasticsearch cluster allows you to update your instance_charge_ype from `PostPaid` to `PrePaid`, the following attributes are required: `period`. Use `payment_type` instead with values `PayAsYouGo` or `Subscription`. * `client_node_spec` - (Optional, Deprecated since v1.261.0) The client node spec. If specified, client node will be created. * `client_node_amount` - (Optional, Deprecated since v1.261.0) The Elasticsearch cluster's client node quantity, between 2 and 25. * `master_node_spec` - (Optional, Deprecated since v1.261.0) The dedicated master node spec. If specified, dedicated master node will be created. @@ -149,58 +172,65 @@ The following arguments will be discarded. Please use new fields as soon as poss ### `client_node_configuration` The client_node_configuration supports the following: -* `amount` - (Optional, Int, Available since v1.267.0) Number of disks in the Elasticsearch cluster coordination node -* `disk` - (Optional, ForceNew, Computed, Int, Available since v1.267.0) Elasticsearch cluster coordinates node disk size -* `disk_type` - (Optional, ForceNew, Available since v1.267.0) Elasticsearch cluster coordination node disk type -* `spec` - (Optional, Available since v1.267.0) Elasticsearch cluster coordination node specification +* `amount` - (Optional, Int, Available since v1.267.0) Number of nodes. +* `disk` - (Optional, ForceNew, Computed, Int, Available since v1.267.0) Node storage capacity, in GB. +* `disk_type` - (Optional, ForceNew, Available since v1.267.0) Storage type of the node. Only ultra disk (cloud_efficiency) is supported. +* `spec` - (Optional) Node specification. You can view specification details in [Product Specifications](https://help.aliyun.com/document_detail/271718.html). ### `data_node_configuration` The data_node_configuration supports the following: -* `amount` - (Optional, Computed, Int, Available since v1.267.0) Number of data nodes in the Elasticsearch cluster -* `disk` - (Optional, Int, Available since v1.267.0) Elasticsearch data node disk size -* `disk_encryption` - (Optional, ForceNew, Computed, Available since v1.267.0) Whether the Elasticsearch data node disk is encrypted -* `disk_type` - (Optional, ForceNew, Computed, Available since v1.267.0) Elasticsearch cluster data node disk type -* `performance_level` - (Optional, Computed, Available since v1.267.0) Elasticsearch cluster data node Essd disk level -* `spec` - (Required, Available since v1.267.0) Elasticsearch data node specification +* `amount` - (Optional, Computed, Int, Available since v1.267.0) Number of data nodes. Valid values: 2 to 50. +* `disk` - (Optional, Int, Available since v1.267.0) Storage capacity per node, in GB. +* `disk_encryption` - (Optional, ForceNew, Computed, Available since v1.267.0) Whether to enable cloud disk encryption: + - true: Enabled + - false: Disabled. +* `disk_type` - (Optional, ForceNew, Computed, Available since v1.267.0) Node disk type. Supported types: + - cloud_ssd: SSD cloud disk + - cloud_efficiency: Ultra cloud disk. +* `performance_level` - (Optional, Computed, Available since v1.267.0) Performance level of ESSD cloud disks. This parameter is required when diskType is set to cloud_essd. Supported values: PL1, PL2, PL3. +* `spec` - (Required, Available since v1.267.0) Node specification. For more information about specifications, see [Product Specifications](https://help.aliyun.com/document_detail/271718.html). ### `kibana_configuration` The kibana_configuration supports the following: -* `amount` - (Optional, ForceNew, Computed, Int, Available since v1.267.0) The number of disks of the Elasticsearch Kibana node. The default value is 1. -* `disk` - (Optional, ForceNew, Computed, Int, Available since v1.267.0) Elasticsearch Kibana node disk size -* `spec` - (Required, Available since v1.267.0) Elasticsearch Kibana node disk specifications +* `amount` - (Optional, ForceNew, Computed, Int, Available since v1.267.0) The number of nodes. +* `disk` - (Optional, ForceNew, Computed, Int, Available since v1.267.0) Storage capacity per node, in GB. +* `spec` - (Required, Available since v1.267.0) Node specification. For specification details, see [Product Specifications](https://help.aliyun.com/document_detail/271718.html). ### `master_configuration` The master_configuration supports the following: -* `amount` - (Optional, ForceNew, Int, Available since v1.267.0) Elasticsearch proprietary master node number of disks -* `disk` - (Optional, ForceNew, Int, Available since v1.267.0) Elasticsearch proprietary master node disk size -* `disk_type` - (Optional, ForceNew, Available since v1.267.0) Elasticsearch proprietary master node disk type -* `spec` - (Optional, Available since v1.267.0) Elasticsearch proprietary master node specifications +* `amount` - (Optional, ForceNew, Int, Available since v1.267.0) Number of nodes. +* `disk` - (Optional, ForceNew, Int, Available since v1.267.0) Node storage capacity, in GB. +* `disk_type` - (Optional, ForceNew, Available since v1.267.0) Node storage type. Only cloud_ssd (SSD cloud disk) is supported. +* `spec` - (Optional, Available since v1.267.0) Node specification. For specifications, see [Product Specifications](https://help.aliyun.com/document_detail/271718.html). ### `warm_node_configuration` The warm_node_configuration supports the following: -* `amount` - (Optional, Int, Available since v1.267.0) Elasticsearch cluster cold data node disk number -* `disk` - (Optional, Int, Available since v1.267.0) Elasticsearch cluster cold data node disk size -* `disk_encryption` - (Optional, ForceNew, Available since v1.267.0) Elasticsearch cluster cold data node Disk encryption -* `disk_type` - (Optional, ForceNew, Available since v1.267.0) Elasticsearch cluster cold data node disk type -* `spec` - (Optional, Available since v1.267.0) Elasticsearch cluster cold data node Disk Specification +* `amount` - (Optional, Int, Available since v1.267.0) Number of nodes. +* `disk` - (Optional, Int, Available since v1.267.0) Storage capacity per node, in GB. +* `disk_encryption` - (Optional, ForceNew, Available since v1.267.0) Whether to enable disk encryption. The values are as follows: + - true: Enabled. + - false: Disabled. +* `disk_type` - (Optional, ForceNew, Available since v1.267.0) Storage type for the node. Only `cloud_efficiency` (ultra disk) is supported. +* `spec` - (Optional, Available since v1.267.0) Node specification. For specifications, see [Product Specifications](https://help.aliyun.com/document_detail/271718.html). ## Attributes Reference The following attributes are exported: * `id` - The ID of the resource supplied above. -* `arch_type` - Schema Type:. -* `create_time` - Instance creation time. -* `domain` - Elasticsearch cluster private domain name. -* `kibana_domain` - Kibana address. -* `kibana_port` - The port assigned by the Kibana node. -* `public_domain` - The public network address of the current instance. -* `public_port` - Elasticsearch cluster public network access port +* `arch_type` - The deployment mode or architecture type:. +* `create_time` - The time when the instance was created. +* `domain` - The internal network address of the instance. +* `kibana_domain` - Kibana endpoint. +* `kibana_port` - The access port for Kibana. +* `kibana_private_domain` - The private endpoint of Kibana. +* `public_domain` - The public endpoint of the instance. +* `public_port` - The public access port of the instance. * `port` - Instance connection port. -* `status` - Instance change status +* `status` - The status of the instance. ## Timeouts diff --git a/website/docs/r/esa_site.html.markdown b/website/docs/r/esa_site.html.markdown index 56cabb712726..8e3d18c6226c 100644 --- a/website/docs/r/esa_site.html.markdown +++ b/website/docs/r/esa_site.html.markdown @@ -77,6 +77,14 @@ The following arguments are supported: * `add_real_client_ip_header` - (Optional, Available since v1.244.0) Add the "ali-real-client-ip" header containing the real client IP. Value range: - `on`: Enable. - `off`: Disable. +* `ai_mode` - (Optional, Computed, Available since v1.272.1) HTTP DDoS Intelligent Protection Mode. Valid values: + - `observe`: Observe. + - `defense`: Block. +* `ai_template` - (Optional, Computed, Available since v1.272.1) HTTP DDoS Intelligent Protection Level. Values: + - `level0`: Very Loose. + - `level30`: Loose. + - `level60`: Normal. + - `level90`: Strict. * `cache_architecture_mode` - (Optional, Computed, Available since v1.244.0) Multi-level cache architecture mode. Possible values: - `edge`: Edge cache layer. - `edge_smart`: Edge cache layer + intelligent cache layer. @@ -102,6 +110,11 @@ The following arguments are supported: * `flatten_mode` - (Optional, Available since v1.251.0) CNAME flattening mode. Possible values: - `flatten_all`: Flatten all. - `flatten_at_root`: Flatten only the root domain. The default is to flatten the root domain. +* `global_mode` - (Optional, Computed, Available since v1.272.1) HTTP DDoS Attack Protection Policy Modes. Valid values: + - `very weak`: indicates a very permissive setting. + - `weak`: indicates a permissive setting. + - `default`: indicates a normal setting. + - `hard`: indicates a strict setting. * `instance_id` - (Required, ForceNew) The ID of the associated package instance. * `ipv6_enable` - (Optional, Computed, Available since v1.244.0) Specifies whether to enable IPv6. Valid values: - `on` @@ -135,8 +148,8 @@ The following attributes are exported: ## Timeouts The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions: -* `create` - (Defaults to 5 mins) Used when create the Site. -* `delete` - (Defaults to 5 mins) Used when delete the Site. +* `create` - (Defaults to 45 mins) Used when create the Site. +* `delete` - (Defaults to 15 mins) Used when delete the Site. * `update` - (Defaults to 5 mins) Used when update the Site. ## Import @@ -144,5 +157,5 @@ The `timeouts` block allows you to specify [timeouts](https://developer.hashicor ESA Site can be imported using the id, e.g. ```shell -$ terraform import alicloud_esa_site.example <id> +$ terraform import alicloud_esa_site.example <site_id> ``` \ No newline at end of file diff --git a/website/docs/r/fc_alias.html.markdown b/website/docs/r/fc_alias.html.markdown index 491619aef4e8..4eea108ea0bf 100644 --- a/website/docs/r/fc_alias.html.markdown +++ b/website/docs/r/fc_alias.html.markdown @@ -20,12 +20,6 @@ Creates a Function Compute service alias. Creates an alias that points to the sp Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_alias&exampleId=ece83230-3dff-a95b-59d1-50065f03e40acf0b9512&activeTab=example&spm=docs.r.fc_alias.0.ece832303d&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" diff --git a/website/docs/r/fc_custom_domain.html.markdown b/website/docs/r/fc_custom_domain.html.markdown index 25695caa9864..86c66b5b903c 100644 --- a/website/docs/r/fc_custom_domain.html.markdown +++ b/website/docs/r/fc_custom_domain.html.markdown @@ -20,12 +20,6 @@ Provides an Alicloud Function Compute custom domain resource. Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_custom_domain&exampleId=60b7149d-0b37-7af9-d227-f803e9272cb4f4f625db&activeTab=example&spm=docs.r.fc_custom_domain.0.60b7149d0b&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform resource "random_integer" "default" { max = 99999 diff --git a/website/docs/r/fc_function.html.markdown b/website/docs/r/fc_function.html.markdown index 7ee5673cc090..1aec494758f2 100644 --- a/website/docs/r/fc_function.html.markdown +++ b/website/docs/r/fc_function.html.markdown @@ -24,12 +24,6 @@ Provides a Alicloud Function Compute Function resource. Function allows you to t Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_function&exampleId=9645cc0b-d182-425a-9800-587b9a58de110464f21b&activeTab=example&spm=docs.r.fc_function.0.9645cc0bd1&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" diff --git a/website/docs/r/fc_function_async_invoke_config.html.markdown b/website/docs/r/fc_function_async_invoke_config.html.markdown index 00286947e27b..8a9484c34ba9 100644 --- a/website/docs/r/fc_function_async_invoke_config.html.markdown +++ b/website/docs/r/fc_function_async_invoke_config.html.markdown @@ -22,12 +22,6 @@ Manages an asynchronous invocation configuration for a FC Function or Alias. -> **NOTE** Ensure the FC Function RAM Role has necessary permissions for the destination, such as `mns:SendMessage`, `mns:PublishMessage` or `fc:InvokeFunction`, otherwise the API will return a generic error. -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_function_async_invoke_config&exampleId=c9b2eee5-8400-74ab-91c2-a98ed4b9ece56b26feec&activeTab=example&spm=docs.r.fc_function_async_invoke_config.0.c9b2eee584&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" diff --git a/website/docs/r/fc_layer_version.html.markdown b/website/docs/r/fc_layer_version.html.markdown index a459c9dbc67c..93584344a455 100644 --- a/website/docs/r/fc_layer_version.html.markdown +++ b/website/docs/r/fc_layer_version.html.markdown @@ -23,12 +23,6 @@ For information about FC Layer Version and how to use it, see [What is Layer Ver Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_layer_version&exampleId=91eb8b93-74c4-09dd-c73e-1c8b2aabeca4ffe5f7ed&activeTab=example&spm=docs.r.fc_layer_version.0.91eb8b9374&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" diff --git a/website/docs/r/fc_service.html.markdown b/website/docs/r/fc_service.html.markdown index 12e86883f561..09aa395005ca 100644 --- a/website/docs/r/fc_service.html.markdown +++ b/website/docs/r/fc_service.html.markdown @@ -30,12 +30,6 @@ For more details supported regions, see [Service endpoints](https://www.alibabac Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_service&exampleId=35d31535-c004-be8f-b8b6-1bedc610f346729e2f9e&activeTab=example&spm=docs.r.fc_service.0.35d31535c0&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" diff --git a/website/docs/r/fc_trigger.html.markdown b/website/docs/r/fc_trigger.html.markdown index b1cb15cd66d5..77c4d4e7839e 100644 --- a/website/docs/r/fc_trigger.html.markdown +++ b/website/docs/r/fc_trigger.html.markdown @@ -22,12 +22,6 @@ Provides an Alicloud Function Compute Trigger resource. Based on trigger, execut Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_trigger&exampleId=f10270d0-14d4-416c-f574-29002e67f3a40b4f4fbd&activeTab=example&spm=docs.r.fc_trigger.0.f10270d014&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform data "alicloud_account" "default" {} data "alicloud_regions" "default" { @@ -149,12 +143,6 @@ EOF MNS topic trigger: -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_trigger&exampleId=04f4d0c3-a376-e4c2-9aab-11d153798b2d63b483eb&activeTab=example&spm=docs.r.fc_trigger.1.04f4d0c3a3&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" @@ -248,12 +236,6 @@ resource "alicloud_fc_trigger" "default" { CDN events trigger: -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_trigger&exampleId=33bbfc00-315e-a4c1-44ac-4df032a1b46a0167ff13&activeTab=example&spm=docs.r.fc_trigger.2.33bbfc0031&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform provider "alicloud" { region = "cn-hangzhou" @@ -377,12 +359,6 @@ EOF EventBridge trigger: -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_fc_trigger&exampleId=5012b39c-cc91-006c-2926-09ba180ba3ac7b724656&activeTab=example&spm=docs.r.fc_trigger.3.5012b39ccc&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform data "alicloud_account" "default" {} data "alicloud_regions" "default" { diff --git a/website/docs/r/live_domain.html.markdown b/website/docs/r/live_domain.html.markdown index e37b3694694b..a1181b88f82b 100644 --- a/website/docs/r/live_domain.html.markdown +++ b/website/docs/r/live_domain.html.markdown @@ -20,6 +20,12 @@ For information about Live Domain and how to use it, see [What is Domain](https: Basic Usage +<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> + <a href="https://api.aliyun.com/terraform?resource=alicloud_live_domain&exampleId=1f2838fb-dded-56b4-3c02-8151c41f11862dcc6e05&activeTab=example&spm=docs.r.live_domain.0.1f2838fbdd&intl_lang=EN_US" target="_blank"> + <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> + </a> +</div></div> + ```terraform provider "alicloud" { region = "cn-hangzhou" @@ -37,6 +43,9 @@ resource "alicloud_live_domain" "default" { } ``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_live_domain&spm=docs.r.live_domain.example&intl_lang=EN_US) + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/max_compute_tenant_role_user_attachment.html.markdown b/website/docs/r/max_compute_tenant_role_user_attachment.html.markdown index 903fbf4a5d91..b3d4ad912daf 100644 --- a/website/docs/r/max_compute_tenant_role_user_attachment.html.markdown +++ b/website/docs/r/max_compute_tenant_role_user_attachment.html.markdown @@ -22,6 +22,12 @@ For information about Max Compute Tenant Role User Attachment and how to use it, Basic Usage +<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> + <a href="https://api.aliyun.com/terraform?resource=alicloud_max_compute_tenant_role_user_attachment&exampleId=145d8862-76ff-5a2f-f507-39f2f80120cd49b6fc27&activeTab=example&spm=docs.r.max_compute_tenant_role_user_attachment.0.145d886276&intl_lang=EN_US" target="_blank"> + <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> + </a> +</div></div> + ```terraform variable "name" { default = "terraform-example" @@ -37,6 +43,9 @@ resource "alicloud_max_compute_tenant_role_user_attachment" "default0" { } ``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_max_compute_tenant_role_user_attachment&spm=docs.r.max_compute_tenant_role_user_attachment.example&intl_lang=EN_US) + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/nlb_hd_monitor_region_config.html.markdown b/website/docs/r/nlb_hd_monitor_region_config.html.markdown new file mode 100644 index 000000000000..4bc1ce1e74f0 --- /dev/null +++ b/website/docs/r/nlb_hd_monitor_region_config.html.markdown @@ -0,0 +1,64 @@ +--- +subcategory: "Network Load Balancer (NLB)" +layout: "alicloud" +page_title: "Alicloud: alicloud_nlb_hd_monitor_region_config" +description: |- + Provides a Alicloud Network Load Balancer (NLB) Hd Monitor Region Config resource. +--- + +# alicloud_nlb_hd_monitor_region_config + +Provides a Network Load Balancer (NLB) Hd Monitor Region Config resource. + +HD monitor config. + +For information about Network Load Balancer (NLB) Hd Monitor Region Config and how to use it, see [What is Hd Monitor Region Config](https://next.api.alibabacloud.com/document/Nlb/2022-04-30/SetHdMonitorRegionConfig). + +-> **NOTE:** Available since v1.273.0. + +## Example Usage + +Basic Usage + +```terraform +variable "name" { + default = "terraform-example" +} + +provider "alicloud" { + region = "cn-beijing" +} + + +resource "alicloud_nlb_hd_monitor_region_config" "default" { + metric_store = "example" + log_project = "example" +} +``` + +## Argument Reference + +The following arguments are supported: +* `log_project` - (Required) The name of the LogProject. +* `metric_store` - (Required) The name of the MetricStore. + +## Attributes Reference + +The following attributes are exported: +* `id` - The ID of the resource supplied above. +* `region_id` - The ID of the region in which the resource resides. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions: +* `create` - (Defaults to 5 mins) Used when create the Hd Monitor Region Config. +* `delete` - (Defaults to 5 mins) Used when delete the Hd Monitor Region Config. +* `update` - (Defaults to 5 mins) Used when update the Hd Monitor Region Config. + +## Import + +Network Load Balancer (NLB) Hd Monitor Region Config can be imported using the id, e.g. + +```shell +$ terraform import alicloud_nlb_hd_monitor_region_config.example <region_id> +``` \ No newline at end of file diff --git a/website/docs/r/oos_patch_baseline.html.markdown b/website/docs/r/oos_patch_baseline.html.markdown index deb3d2c00758..7105abaff687 100644 --- a/website/docs/r/oos_patch_baseline.html.markdown +++ b/website/docs/r/oos_patch_baseline.html.markdown @@ -20,6 +20,12 @@ For information about Operation Orchestration Service (OOS) Patch Baseline and h Basic Usage +<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> + <a href="https://api.aliyun.com/terraform?resource=alicloud_oos_patch_baseline&exampleId=e2afef21-97cf-661b-b70a-4fe0cdcf1aa760c34163&activeTab=example&spm=docs.r.oos_patch_baseline.0.e2afef2197&intl_lang=EN_US" target="_blank"> + <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> + </a> +</div></div> + ```terraform variable "name" { default = "terraform-example" @@ -33,6 +39,9 @@ resource "alicloud_oos_patch_baseline" "default" { } ``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_oos_patch_baseline&spm=docs.r.oos_patch_baseline.example&intl_lang=EN_US) + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/oss_bucket.html.markdown b/website/docs/r/oss_bucket.html.markdown index dd49d93cb95f..58de63c401db 100644 --- a/website/docs/r/oss_bucket.html.markdown +++ b/website/docs/r/oss_bucket.html.markdown @@ -15,6 +15,8 @@ Provides a resource to create a oss bucket and set its attribution. -> **NOTE:** Available since v1.2.0. +-> **NOTE:** When using standalone sub-resources (e.g., `alicloud_oss_bucket_policy`, `alicloud_oss_bucket_logging`, `alicloud_oss_bucket_cors`, `alicloud_oss_bucket_website`, `alicloud_oss_bucket_versioning`, `alicloud_oss_bucket_referer`, `alicloud_oss_bucket_server_side_encryption`, `alicloud_oss_bucket_transfer_acceleration`, `alicloud_oss_bucket_acl`) alongside `alicloud_oss_bucket`, you **must** add a [`lifecycle`](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle) block with `ignore_changes` for the corresponding attribute on `alicloud_oss_bucket`. This prevents Terraform from detecting spurious diffs caused by the same configuration being managed by both the bucket resource and the standalone sub-resource. Without `ignore_changes`, Terraform may attempt to revert changes made by the sub-resource on every apply, causing unexpected behavior. + ## Example Usage Private Bucket @@ -362,6 +364,64 @@ resource "alicloud_oss_bucket_acl" "default" { } ``` +Using sub-resources with ignore_changes + +When managing bucket configurations through standalone sub-resources such as `alicloud_oss_bucket_policy`, `alicloud_oss_bucket_logging`, or `alicloud_oss_bucket_cors`, you must use a `lifecycle` block with `ignore_changes` on the `alicloud_oss_bucket` to prevent Terraform from detecting configuration drift. The sub-resource manages the corresponding attribute independently, so without `ignore_changes`, Terraform will see the attribute value differ from the bucket's inline configuration and attempt to revert it on every plan/apply. + +```terraform +resource "random_integer" "default" { + max = 99999 + min = 10000 +} + +resource "alicloud_oss_bucket" "example" { + bucket = "example-sub-resources-${random_integer.default.result}" + + # When using standalone sub-resources to manage bucket configurations, + # you must add `ignore_changes` for the corresponding attributes. + # Otherwise, Terraform will detect a diff between the inline attribute + # and the sub-resource, and attempt to revert the sub-resource's changes. + lifecycle { + ignore_changes = [ + policy, + logging, + website, + cors_rule, + versioning, + referer_config, + server_side_encryption_rule, + transfer_acceleration, + ] + } +} + +resource "alicloud_oss_bucket_acl" "example" { + bucket = alicloud_oss_bucket.example.bucket + acl = "private" +} + +resource "alicloud_oss_bucket_policy" "example" { + bucket = alicloud_oss_bucket.example.bucket + policy = jsonencode({ + "Version" : "1", + "Statement" : [{ + "Action" : ["oss:PutObject", "oss:GetObject"], + "Effect" : "Deny", + "Principal" : ["1234567890"], + "Resource" : ["acs:oss:*:1234567890:*/*"] + }] + }) +} + +resource "alicloud_oss_bucket_logging" "example" { + bucket = alicloud_oss_bucket.example.bucket + target_bucket = alicloud_oss_bucket.example.bucket + target_prefix = "log/" +} +``` + +-> **NOTE:** You only need to include the attributes in `ignore_changes` that correspond to the sub-resources you are actually using. For example, if you only use `alicloud_oss_bucket_policy`, you only need `ignore_changes = [policy]`. + IA Bucket <div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> diff --git a/website/docs/r/oss_bucket_cors.html.markdown b/website/docs/r/oss_bucket_cors.html.markdown index 2f23e487d1a6..cc60f60eaf05 100644 --- a/website/docs/r/oss_bucket_cors.html.markdown +++ b/website/docs/r/oss_bucket_cors.html.markdown @@ -41,6 +41,8 @@ resource "alicloud_oss_bucket" "CreateBucket" { storage_class = "Standard" bucket = "${var.name}-${random_uuid.default.result}" lifecycle { + # When you use `alicloud_oss_bucket_cors`, you must add `ignore_changes` for the `cors_rule` attribute + # on `alicloud_oss_bucket` to avoid unexpected diffs caused by both resources managing the same configuration. ignore_changes = [ cors_rule, ] diff --git a/website/docs/r/oss_bucket_policy.html.markdown b/website/docs/r/oss_bucket_policy.html.markdown index 69447774d5eb..5f40ee250565 100644 --- a/website/docs/r/oss_bucket_policy.html.markdown +++ b/website/docs/r/oss_bucket_policy.html.markdown @@ -42,6 +42,8 @@ resource "alicloud_oss_bucket" "CreateBucket" { storage_class = "Standard" bucket = "${var.name}-${random_integer.default.result}" lifecycle { + # When you use `alicloud_oss_bucket_policy`, you must add `ignore_changes` for the `policy` attribute + # on `alicloud_oss_bucket` to avoid unexpected diffs caused by both resources managing the same configuration. ignore_changes = [ policy, ] diff --git a/website/docs/r/oss_bucket_referer.html.markdown b/website/docs/r/oss_bucket_referer.html.markdown index f7bbdcad87af..2d44f6854ce3 100644 --- a/website/docs/r/oss_bucket_referer.html.markdown +++ b/website/docs/r/oss_bucket_referer.html.markdown @@ -42,6 +42,8 @@ resource "alicloud_oss_bucket" "CreateBucket" { storage_class = "Standard" bucket = "${var.name}-${random_integer.default.result}" lifecycle { + # When you use `alicloud_oss_bucket_referer`, you must add `ignore_changes` for the `referer_config` attribute + # on `alicloud_oss_bucket` to avoid unexpected diffs caused by both resources managing the same configuration. ignore_changes = [ referer_config, ] diff --git a/website/docs/r/oss_bucket_server_side_encryption.html.markdown b/website/docs/r/oss_bucket_server_side_encryption.html.markdown index 89fde4f185f7..bb17cdb88878 100644 --- a/website/docs/r/oss_bucket_server_side_encryption.html.markdown +++ b/website/docs/r/oss_bucket_server_side_encryption.html.markdown @@ -42,6 +42,9 @@ resource "alicloud_oss_bucket" "CreateBucket" { storage_class = "Standard" bucket = "${var.name}-${random_integer.default.result}" lifecycle { + # When you use `alicloud_oss_bucket_server_side_encryption`, you must add `ignore_changes` for the + # `server_side_encryption_rule` attribute on `alicloud_oss_bucket` to avoid unexpected diffs caused by + # both resources managing the same configuration. ignore_changes = [ server_side_encryption_rule, ] diff --git a/website/docs/r/oss_bucket_transfer_acceleration.html.markdown b/website/docs/r/oss_bucket_transfer_acceleration.html.markdown index dd8efcd840ba..0276a15dcedd 100644 --- a/website/docs/r/oss_bucket_transfer_acceleration.html.markdown +++ b/website/docs/r/oss_bucket_transfer_acceleration.html.markdown @@ -43,6 +43,9 @@ resource "alicloud_oss_bucket" "CreateBucket" { storage_class = "Standard" bucket = "${var.name}-${random_integer.default.result}" lifecycle { + # When you use `alicloud_oss_bucket_transfer_acceleration`, you must add `ignore_changes` for the + # `transfer_acceleration` attribute on `alicloud_oss_bucket` to avoid unexpected diffs caused by + # both resources managing the same configuration. ignore_changes = [ transfer_acceleration, ] diff --git a/website/docs/r/oss_bucket_versioning.html.markdown b/website/docs/r/oss_bucket_versioning.html.markdown index ce9565cb8a72..8ed4fe25a827 100644 --- a/website/docs/r/oss_bucket_versioning.html.markdown +++ b/website/docs/r/oss_bucket_versioning.html.markdown @@ -42,6 +42,8 @@ resource "alicloud_oss_bucket" "CreateBucket" { storage_class = "Standard" bucket = "${var.name}-${random_integer.default.result}" lifecycle { + # When you use `alicloud_oss_bucket_versioning`, you must add `ignore_changes` for the `versioning` attribute + # on `alicloud_oss_bucket` to avoid unexpected diffs caused by both resources managing the same configuration. ignore_changes = [ versioning, ] diff --git a/website/docs/r/oss_bucket_website.html.markdown b/website/docs/r/oss_bucket_website.html.markdown index 9739c8e86265..2d814071d38a 100644 --- a/website/docs/r/oss_bucket_website.html.markdown +++ b/website/docs/r/oss_bucket_website.html.markdown @@ -42,6 +42,8 @@ resource "alicloud_oss_bucket" "defaultnVj9x3" { bucket = "${var.name}-${random_uuid.default.result}" storage_class = "Standard" lifecycle { + # When you use `alicloud_oss_bucket_website`, you must add `ignore_changes` for the `website` attribute + # on `alicloud_oss_bucket` to avoid unexpected diffs caused by both resources managing the same configuration. ignore_changes = [website] } } diff --git a/website/docs/r/rds_backup.html.markdown b/website/docs/r/rds_backup.html.markdown index d961b809396a..690dc387c882 100644 --- a/website/docs/r/rds_backup.html.markdown +++ b/website/docs/r/rds_backup.html.markdown @@ -2,7 +2,6 @@ subcategory: "RDS" layout: "alicloud" page_title: "Alicloud: alicloud_rds_backup" -sidebar_current: "docs-alicloud-resource-rds-backup" description: |- Provides a Alicloud RDS Backup resource. --- @@ -11,6 +10,8 @@ description: |- Provides a RDS Backup resource. +Backup object at the instance level or database level. + For information about RDS Backup and how to use it, see [What is Backup](https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createbackup). -> **NOTE:** Available since v1.149.0. @@ -19,12 +20,6 @@ For information about RDS Backup and how to use it, see [What is Backup](https:/ Basic Usage -<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> - <a href="https://api.aliyun.com/terraform?resource=alicloud_rds_backup&exampleId=e8067d24-c7ba-faf2-88e6-b2c5d35cf357bf1d9822&activeTab=example&spm=docs.r.rds_backup.0.e8067d24c7&intl_lang=EN_US" target="_blank"> - <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> - </a> -</div></div> - ```terraform resource "alicloud_db_instance" "example" { engine = "MySQL" @@ -40,43 +35,68 @@ resource "alicloud_rds_backup" "example" { } ``` -📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_rds_backup&spm=docs.r.rds_backup.example&intl_lang=EN_US) - ## Argument Reference The following arguments are supported: +* `backup_method` - (Optional, ForceNew, Computed) The backup type. Valid values: +* `Logical`: logical backup (supported only for MySQL) +* `Physical`: physical backup (supported for MySQL, SQL Server, and PostgreSQL) +* `Snapshot`: snapshot backup (supported for all database engines) -* `backup_method` - (Optional, ForceNew) The type of backup that you want to perform. Default value: `Physical`. Valid values: `Logical`, `Physical` and `Snapshot`. -* `backup_strategy` - (Optional) The policy that you want to use for the backup task. Valid values: - * **db**: specifies to perform a database-level backup. - * **instance**: specifies to perform an instance-level backup. -* `backup_type` - (Optional, ForceNew) The method that you want to use for the backup task. Default value: `Auto`. Valid values: - * **Auto**: specifies to automatically perform a full or incremental backup. - * **FullBackup**: specifies to perform a full backup. -* `db_instance_id` - (Required, ForceNew) The db instance id. -* `db_name` - (Optional) The names of the databases whose data you want to back up. Separate the names of the databases with commas (,). -* `remove_from_state` - (Optional) Remove form state when resource cannot be deleted. Valid values: `true` and `false`. +Default value: `Physical`. + +-> **NOTE:** * When using logical backup, the database must contain data (the data cannot be empty). + +-> **NOTE:** * MariaDB instances support only snapshot backup, but you must specify `Physical` for this parameter. + +* `backup_retention_period` - (Optional, Int, Available since v1.273.0) When the database engine is SQL Server, `BackupStrategy` is set to `db`, `BackupMethod` is `Physical`, and `BackupType` is `FullBackup`, you can specify the retention period for the backup set. Valid values: 7 to 730 days, or - 1 (permanent retention). + +-> **NOTE:** This parameter is immutable. Changing it after creation has no effect. + +* `backup_strategy` - (Optional) The backup strategy. Valid values: +* `db`: Single-database backup +* `instance`: Instance-level backup + +-> **NOTE:** This parameter takes effect only under the following conditions: + +-> **NOTE:** - MySQL: The `BackupMethod` parameter is specified and set to `Logical`. +-> **NOTE:** - SQL Server: The `BackupType` parameter is specified and set to `FullBackup`. + + +-> **NOTE:** This parameter is immutable. Changing it after creation has no effect. + +* `backup_type` - (Optional, ForceNew, Computed) The backup type. Valid values: + - FullBackup: full backup + - IncrementalBackup: incremental backup +* `db_instance_id` - (Required, ForceNew) The instance ID. You can call DescribeDBInstances to obtain it. +* `db_name` - (Optional) A list of databases, separated by commas (,). + +-> **NOTE:** This parameter takes effect only when the `BackupStrategy` parameter is specified and its value is `db`. + + +-> **NOTE:** This parameter is immutable. Changing it after creation has no effect. + +* `remove_from_state` - (Optional) Remove form state when resource cannot be deleted. Valid values: `true` and `false`. ## Attributes Reference The following attributes are exported: - -* `id` - The resource ID in terraform of Backup. -* `backup_id` - The backup id. -* `store_status` - Indicates whether the data backup file can be deleted. Valid values: `Enabled` and `Disabled`. +* `id` - The ID of the resource supplied above. +* `backup_id` - The backup set ID. +* `status` - The status of the resource. +* `store_status` - Indicates whether the backup can be deleted. ## Timeouts The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions: - -* `create` - (Defaults to 20 mins) Used when creating the backup. -* `delete` - (Defaults to 20 mins) Used when deleting the backup. +* `create` - (Defaults to 5 mins) Used when create the Backup. +* `delete` - (Defaults to 5 mins) Used when delete the Backup. ## Import RDS Backup can be imported using the id, e.g. ```shell -$ terraform import alicloud_rds_backup.example <db_instance_id>:<backup_id> -``` +$ terraform import alicloud_rds_backup.example <backup_id> +``` \ No newline at end of file diff --git a/website/docs/r/vpc_ipam_ipam.html.markdown b/website/docs/r/vpc_ipam_ipam.html.markdown index 939f5d599987..cc42384e1000 100644 --- a/website/docs/r/vpc_ipam_ipam.html.markdown +++ b/website/docs/r/vpc_ipam_ipam.html.markdown @@ -20,6 +20,12 @@ For information about Vpc Ipam Ipam and how to use it, see [What is Ipam](https: Basic Usage +<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> + <a href="https://api.aliyun.com/terraform?resource=alicloud_vpc_ipam_ipam&exampleId=b459cbe2-7f5c-1a5b-7669-f4ec31cc9b1a233f7262&activeTab=example&spm=docs.r.vpc_ipam_ipam.0.b459cbe27f&intl_lang=EN_US" target="_blank"> + <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> + </a> +</div></div> + ```terraform variable "name" { default = "terraform-example" @@ -39,6 +45,9 @@ resource "alicloud_vpc_ipam_ipam" "default" { } ``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_vpc_ipam_ipam&spm=docs.r.vpc_ipam_ipam.example&intl_lang=EN_US) + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/vpc_ipam_ipam_pool.html.markdown b/website/docs/r/vpc_ipam_ipam_pool.html.markdown index 2ae8eb8f7fd1..c8edffefceda 100644 --- a/website/docs/r/vpc_ipam_ipam_pool.html.markdown +++ b/website/docs/r/vpc_ipam_ipam_pool.html.markdown @@ -20,6 +20,12 @@ For information about Vpc Ipam Ipam Pool and how to use it, see [What is Ipam Po Basic Usage +<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> + <a href="https://api.aliyun.com/terraform?resource=alicloud_vpc_ipam_ipam_pool&exampleId=2a160962-cd7a-9d64-32d2-d2a0f8a3cf67cf4b594f&activeTab=example&spm=docs.r.vpc_ipam_ipam_pool.0.2a160962cd&intl_lang=EN_US" target="_blank"> + <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> + </a> +</div></div> + ```terraform variable "name" { default = "terraform-example" @@ -49,6 +55,9 @@ resource "alicloud_vpc_ipam_ipam_pool" "default" { } ``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_vpc_ipam_ipam_pool&spm=docs.r.vpc_ipam_ipam_pool.example&intl_lang=EN_US) + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/vpc_ipam_ipam_pool_cidr.html.markdown b/website/docs/r/vpc_ipam_ipam_pool_cidr.html.markdown index 36dd1841aafb..c2ea075eebe4 100644 --- a/website/docs/r/vpc_ipam_ipam_pool_cidr.html.markdown +++ b/website/docs/r/vpc_ipam_ipam_pool_cidr.html.markdown @@ -20,6 +20,12 @@ For information about Vpc Ipam Ipam Pool Cidr and how to use it, see [What is Ip Basic Usage +<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;"> + <a href="https://api.aliyun.com/terraform?resource=alicloud_vpc_ipam_ipam_pool_cidr&exampleId=2bdf0a0e-120f-0618-a92c-ba0a26dc8d1d4cbc241d&activeTab=example&spm=docs.r.vpc_ipam_ipam_pool_cidr.0.2bdf0a0e12&intl_lang=EN_US" target="_blank"> + <img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;"> + </a> +</div></div> + ```terraform variable "name" { default = "terraform-example" @@ -46,6 +52,9 @@ resource "alicloud_vpc_ipam_ipam_pool_cidr" "default" { } ``` + +📚 Need more examples? [VIEW MORE EXAMPLES](https://api.aliyun.com/terraform?activeTab=sample&source=Sample&sourcePath=OfficialSample:alicloud_vpc_ipam_ipam_pool_cidr&spm=docs.r.vpc_ipam_ipam_pool_cidr.example&intl_lang=EN_US) + ## Argument Reference The following arguments are supported: diff --git a/website/docs/r/vpc_nat_ip_cidr.html.markdown b/website/docs/r/vpc_nat_ip_cidr.html.markdown index 8fe1c76b37fe..ef2ef7e7a85e 100644 --- a/website/docs/r/vpc_nat_ip_cidr.html.markdown +++ b/website/docs/r/vpc_nat_ip_cidr.html.markdown @@ -2,18 +2,19 @@ subcategory: "NAT Gateway" layout: "alicloud" page_title: "Alicloud: alicloud_vpc_nat_ip_cidr" -sidebar_current: "docs-alicloud-resource-vpc-nat-ip-cidr" description: |- - Provides a Alicloud VPC Nat Ip Cidr resource. + Provides a Alicloud Nat Gateway Nat Ip Cidr resource. --- -# alicloud\_vpc\_nat\_ip\_cidr +# alicloud_vpc_nat_ip_cidr -Provides a VPC Nat Ip Cidr resource. +Provides a Nat Gateway Nat Ip Cidr resource. -For information about VPC Nat Ip Cidr and how to use it, see [What is Nat Ip Cidr](https://www.alibabacloud.com/help/doc-detail/281972.htm). +NAT IP address segment. --> **NOTE:** Available in v1.136.0+. +For information about Nat Gateway Nat Ip Cidr and how to use it, see [What is Nat Ip Cidr](https://www.alibabacloud.com/help/doc-detail/281972.htm). + +-> **NOTE:** Available since v1.136.0. ## Example Usage @@ -26,34 +27,34 @@ Basic Usage </div></div> ```terraform -data "alicloud_zones" "example" { +data "alicloud_zones" "default" { available_resource_creation = "VSwitch" } -resource "alicloud_vpc" "example" { +resource "alicloud_vpc" "default" { vpc_name = "terraform-example" cidr_block = "172.16.0.0/12" } -resource "alicloud_vswitch" "example" { - vpc_id = alicloud_vpc.example.id +resource "alicloud_vswitch" "default" { + vpc_id = alicloud_vpc.default.id cidr_block = "172.16.0.0/21" - zone_id = data.alicloud_zones.example.zones.0.id + zone_id = data.alicloud_zones.default.zones.0.id vswitch_name = "terraform-example" } -resource "alicloud_nat_gateway" "example" { - vpc_id = alicloud_vpc.example.id +resource "alicloud_nat_gateway" "default" { + vpc_id = alicloud_vpc.default.id internet_charge_type = "PayByLcu" nat_gateway_name = "terraform-example" description = "terraform-example" nat_type = "Enhanced" - vswitch_id = alicloud_vswitch.example.id + vswitch_id = alicloud_vswitch.default.id network_type = "intranet" } -resource "alicloud_vpc_nat_ip_cidr" "example" { - nat_gateway_id = alicloud_nat_gateway.example.id +resource "alicloud_vpc_nat_ip_cidr" "default" { + nat_gateway_id = alicloud_nat_gateway.default.id nat_ip_cidr_name = "terraform-example" nat_ip_cidr = "192.168.0.0/16" } @@ -65,22 +66,44 @@ resource "alicloud_vpc_nat_ip_cidr" "example" { The following arguments are supported: -* `dry_run` - (Optional, Computed) Specifies whether to precheck this request only. Valid values: `true` and `false`. -* `nat_gateway_id` - (Required, ForceNew) The ID of the Virtual Private Cloud (VPC) NAT gateway where you want to create the NAT CIDR block. -* `nat_ip_cidr_description` - (Optional) The description of the NAT CIDR block. The description must be `2` to `256` characters in length. It must start with a letter but cannot start with `http://` or `https://`. -* `nat_ip_cidr_name` - (Optional) The name of the NAT CIDR block. The name must be `2` to `128` characters in length and can contain digits, periods (.), underscores (_), and hyphens (-). It must start with a letter. It must start with a letter but cannot start with `http://` or `https://`. -* `nat_ip_cidr` (Optional, ForceNew) - The NAT CIDR block to be created. The CIDR block must meet the following conditions: It must be `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, or one of their subnets. The subnet mask must be `16` to `32` bits in lengths. To use a public CIDR block as the NAT CIDR block, the VPC to which the VPC NAT gateway belongs must be authorized to use public CIDR blocks. For more information, see [Create a VPC NAT gateway](https://www.alibabacloud.com/help/doc-detail/268230.htm). +* `dry_run` - (Optional) Specifies whether to only precheck this request. Valid values: + - `true`: Sends a dry-run request without creating the NAT IP CIDR block. The system checks whether required parameters are specified, whether the request format is valid, and whether the request complies with service limits. If the check fails, an error is returned. If the check passes, the error code `DryRunOperation` is returned. + - `false` (default): Sends a normal request. If the check passes, an HTTP 2xx status code is returned and the operation is performed.* `nat_gateway_id` - (Required, ForceNew) The ID of the Virtual Private Cloud (VPC) NAT gateway where you want to create the NAT CIDR block. + +-> **NOTE:** This parameter only applies during resource creation, update or deletion. If modified in isolation without other property changes, Terraform will not trigger any action. + +* `nat_gateway_id` - (Required, ForceNew) The ID of the VPC NAT gateway instance to which the NAT IP address block belongs. +* `nat_ip_cidr` - (Required, ForceNew) The NAT IP CIDR block to create. + +The newly created CIDR block must meet the following requirements: +- It must belong to the 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16 CIDR blocks or their subnets. +- The subnet mask length must be between 16 and 32 bits. +- It must not overlap with the private CIDR block of the VPC to which the VPC NAT gateway belongs. If you need to translate a private IP address to another address within the VPC's private CIDR block, create a vSwitch in the corresponding VPC private CIDR block and then create a new VPC NAT gateway in that vSwitch to provide private address translation. +- If you want to use a public CIDR block as the NAT IP CIDR block, the CIDR block must belong to the customer CIDR block of the VPC to which the VPC NAT gateway belongs. For more information about customer CIDR blocks, see [What is a customer CIDR block?](https://help.aliyun.com/document_detail/185311.html). +* `nat_ip_cidr_description` - (Optional) The description of the NAT IP CIDR block to modify. + The description must be 2 to 256 characters in length, start with a letter or Chinese character, and cannot start with `http://` or `https://`. +* `nat_ip_cidr_name` - (Required) The name of the NAT IP address block. + The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). It must start with a letter or a Chinese character, and cannot start with `http://` or `https://`. ## Attributes Reference The following attributes are exported: +* `id` - The ID of the resource supplied above. The value is formulated as `<nat_gateway_id>:<nat_ip_cidr>`. +* `create_time` - (Available since v1.273.0) The time when the NAT IP CIDR block was created. +* `status` - The status of the NAT IP CIDR block to query. + +## Timeouts + +-> **NOTE:** Available since v1.273.0. -* `id` - The resource ID of Nat Ip Cidr. The value formats as `<nat_gateway_id>:<nat_ip_cidr>`. -* `status` - The status of the CIDR block of the NAT gateway. Valid values: `Available`. +The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts) for certain actions: +* `create` - (Defaults to 5 mins) Used when create the Nat Ip Cidr. +* `delete` - (Defaults to 5 mins) Used when delete the Nat Ip Cidr. +* `update` - (Defaults to 5 mins) Used when update the Nat Ip Cidr. ## Import -VPC Nat Ip Cidr can be imported using the id, e.g. +Nat Gateway Nat Ip Cidr can be imported using the id, e.g. ```shell $ terraform import alicloud_vpc_nat_ip_cidr.example <nat_gateway_id>:<nat_ip_cidr>