├── .buildkite ├── acceptance.sh ├── acceptance_pipeline.yml ├── hooks │ ├── pre-command │ └── pre-exit ├── pull-requests.json ├── release.sh └── release_pipeline.yml ├── .changelog ├── .gitkeep ├── 814.txt ├── 817.txt ├── 820.txt ├── 821.txt ├── 823.txt ├── 855.txt ├── 858.txt ├── 859.txt ├── 860.txt ├── 869.txt └── 878.txt ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ ├── FEATURE_REQUEST.md │ └── GENERIC_QUESTION.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── comment-on-asciidoc-changes.yml │ └── go.yml ├── .gitignore ├── .golangci.yaml ├── .goreleaser.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── build ├── Makefile.build ├── Makefile.deps ├── Makefile.dev ├── Makefile.format ├── Makefile.lint ├── Makefile.release ├── Makefile.test ├── Makefile.tools └── Makefile.version ├── catalog-info.yaml ├── developer_docs └── RELEASE.md ├── docs-elastic └── index.asciidoc ├── docs ├── data-sources │ ├── aws_privatelink_endpoint.md │ ├── azure_privatelink_endpoint.md │ ├── deployment.md │ ├── deployment_templates.md │ ├── deployments.md │ ├── gcp_private_service_connect_endpoint.md │ ├── stack.md │ └── traffic_filter.md ├── guides │ └── configuring-sso-ec-deployment.md ├── index.md └── resources │ ├── deployment.md │ ├── deployment_elasticsearch_keystore.md │ ├── deployment_extension.md │ ├── deployment_traffic_filter.md │ ├── deployment_traffic_filter_association.md │ ├── elasticsearch_project.md │ ├── observability_project.md │ ├── organization.md │ ├── security_project.md │ └── snapshot_repository.md ├── ec ├── acc │ ├── acc_prereq.go │ ├── datasource_deployment_basic_test.go │ ├── datasource_deploymenttemplates_test.go │ ├── datasource_stack_test.go │ ├── datasource_tags_test.go │ ├── datasource_traffic_filter_test.go │ ├── deployment_add_dedicated_master_test.go │ ├── deployment_autoscaling_test.go │ ├── deployment_basic_defaults_test.go │ ├── deployment_basic_tags_test.go │ ├── deployment_basic_test.go │ ├── deployment_ccs_test.go │ ├── deployment_checks_test.go │ ├── deployment_config_test.go │ ├── deployment_cpu_optimized_test.go │ ├── deployment_dedicated_test.go │ ├── deployment_destroy_test.go │ ├── deployment_docker_image_override_test.go │ ├── deployment_elasticsearch_kesytore_destroy_test.go │ ├── deployment_elasticsearch_keystore_test.go │ ├── deployment_emptyconf_test.go │ ├── deployment_extension_basic_test.go │ ├── deployment_extension_bundle_file_test.go │ ├── deployment_extension_destroy_test.go │ ├── deployment_extension_plugin_download_test.go │ ├── deployment_failed_upgrade_retry_test.go │ ├── deployment_fixture_test.go │ ├── deployment_general_purpose_test.go │ ├── deployment_integrations_server_test.go │ ├── deployment_keystore_test.go │ ├── deployment_migrate_to_latest_hw_test.go │ ├── deployment_ml_only_autoscale_test.go │ ├── deployment_observability_self_test.go │ ├── deployment_observability_test.go │ ├── deployment_post_node_role_upgrade_test.go │ ├── deployment_pre_node_role_migration_test.go │ ├── deployment_snapshot_test.go │ ├── deployment_sweep_test.go │ ├── deployment_sweep_test_test.go │ ├── deployment_template_migration_test.go │ ├── deployment_traffic_filter_association_test.go │ ├── deployment_traffic_filter_checks_test.go │ ├── deployment_traffic_filter_destroy_test.go │ ├── deployment_traffic_filter_sweep_test.go │ ├── deployment_traffic_filter_test.go │ ├── deployment_with_extension_bundle_test.go │ ├── elasticsearch_project_test.go │ ├── observability_project_test.go │ ├── security_project_test.go │ ├── sweep_test.go │ └── testdata │ │ ├── datasource_deployment_basic.tf │ │ ├── datasource_deploymenttemplates.tf │ │ ├── datasource_stack_latest.tf │ │ ├── datasource_stack_regex.tf │ │ ├── datasource_tags.tf │ │ ├── datasource_trafficfilter.tf │ │ ├── deployment_autoscale_ml.tf │ │ ├── deployment_autoscale_ml_2.tf │ │ ├── deployment_autoscaling_1.tf │ │ ├── deployment_autoscaling_2.tf │ │ ├── deployment_basic.tf │ │ ├── deployment_basic_defaults_1.tf │ │ ├── deployment_basic_defaults_2.tf │ │ ├── deployment_basic_defaults_3.tf │ │ ├── deployment_basic_defaults_hw_1.tf │ │ ├── deployment_basic_defaults_hw_2.tf │ │ ├── deployment_basic_integrations_server_1.tf │ │ ├── deployment_basic_integrations_server_2.tf │ │ ├── deployment_basic_reset_password.tf │ │ ├── deployment_basic_settings_config_1.tf │ │ ├── deployment_basic_settings_config_2.tf │ │ ├── deployment_basic_settings_config_import.tf │ │ ├── deployment_basic_tags_1.tf │ │ ├── deployment_basic_tags_2.tf │ │ ├── deployment_basic_tags_3.tf │ │ ├── deployment_basic_tags_4.tf │ │ ├── deployment_basic_with_traffic_filter_2.tf │ │ ├── deployment_basic_with_traffic_filter_3.tf │ │ ├── deployment_ccs_1.tf │ │ ├── deployment_ccs_2.tf │ │ ├── deployment_cpu_optimized_1.tf │ │ ├── deployment_cpu_optimized_2.tf │ │ ├── deployment_cpu_optimized_with_custom_hot_ic.tf │ │ ├── deployment_cpu_optimized_with_migrate_to_latest_hw.tf │ │ ├── deployment_dedicated_coordinating.tf │ │ ├── deployment_dedicated_master_5_nodes.tf │ │ ├── deployment_dedicated_master_6_nodes.tf │ │ ├── deployment_dedicated_master_above_threshold.tf │ │ ├── deployment_dedicated_master_below_threshold.tf │ │ ├── deployment_docker_image_override.tf │ │ ├── deployment_elasticsearch_keystore_1.tf │ │ ├── deployment_elasticsearch_keystore_1_041.tf │ │ ├── deployment_elasticsearch_keystore_1_migrated.tf │ │ ├── deployment_elasticsearch_keystore_2.tf │ │ ├── deployment_elasticsearch_keystore_3.tf │ │ ├── deployment_elasticsearch_keystore_4.tf │ │ ├── deployment_elasticsearch_keystore_creds.json │ │ ├── deployment_emptyconfig.tf │ │ ├── deployment_enterprise_search_1.tf │ │ ├── deployment_enterprise_search_2.tf │ │ ├── deployment_general_purpose_1.tf │ │ ├── deployment_general_purpose_2.tf │ │ ├── deployment_keystore_create.tf │ │ ├── deployment_keystore_update1.tf │ │ ├── deployment_keystore_update2.tf │ │ ├── deployment_keystore_update3.tf │ │ ├── deployment_keystore_update4.tf │ │ ├── deployment_memory_optimized_1.tf │ │ ├── deployment_memory_optimized_2.tf │ │ ├── deployment_observability_1.tf │ │ ├── deployment_observability_2.tf │ │ ├── deployment_observability_3.tf │ │ ├── deployment_observability_4.tf │ │ ├── deployment_observability_self.tf │ │ ├── deployment_observability_tpl_1.tf │ │ ├── deployment_observability_tpl_2.tf │ │ ├── deployment_post_node_roles_upgrade_1.tf │ │ ├── deployment_post_node_roles_upgrade_2.tf │ │ ├── deployment_post_node_roles_upgrade_3.tf │ │ ├── deployment_pre_node_roles_migration_1.tf │ │ ├── deployment_pre_node_roles_migration_2.tf │ │ ├── deployment_pre_node_roles_migration_3.tf │ │ ├── deployment_security_1.tf │ │ ├── deployment_security_2.tf │ │ ├── deployment_snapshot_1.tf │ │ ├── deployment_snapshot_2.tf │ │ ├── deployment_traffic_filter_association_basic.tf │ │ ├── deployment_traffic_filter_association_basic_041.tf │ │ ├── deployment_traffic_filter_association_basic_ignore_changes.tf │ │ ├── deployment_traffic_filter_association_basic_update.tf │ │ ├── deployment_traffic_filter_azure.tf │ │ ├── deployment_traffic_filter_basic.tf │ │ ├── deployment_traffic_filter_basic_update.tf │ │ ├── deployment_traffic_filter_basic_update_large.tf │ │ ├── deployment_upgrade_retry_1.tf │ │ ├── deployment_upgrade_retry_2.tf │ │ ├── deployment_with_extension_bundle_file.tf │ │ ├── extension_basic.tf │ │ ├── extension_bundle_file.tf │ │ └── extension_plugin_download.tf ├── ecdatasource │ ├── deploymentdatasource │ │ ├── datasource.go │ │ ├── datasource_test.go │ │ ├── flatteners_apm.go │ │ ├── flatteners_apm_test.go │ │ ├── flatteners_elasticsearch.go │ │ ├── flatteners_elasticsearch_test.go │ │ ├── flatteners_enterprise_search.go │ │ ├── flatteners_enterprise_search_test.go │ │ ├── flatteners_integrations_server.go │ │ ├── flatteners_integrations_server_test.go │ │ ├── flatteners_kibana.go │ │ ├── flatteners_kibana_test.go │ │ ├── flatteners_observability.go │ │ ├── flatteners_observability_test.go │ │ ├── flatteners_traffic_filter.go │ │ ├── flatteners_traffic_filter_test.go │ │ ├── schema.go │ │ ├── schema_apm.go │ │ ├── schema_elasticsearch.go │ │ ├── schema_enterprise_search.go │ │ ├── schema_integrations_server.go │ │ ├── schema_kibana.go │ │ └── schema_observability.go │ ├── deploymentsdatasource │ │ ├── datasource.go │ │ ├── datasource_test.go │ │ ├── expanders.go │ │ ├── expanders_test.go │ │ └── schema.go │ ├── deploymenttemplates │ │ ├── datasource.go │ │ ├── model.go │ │ ├── model_elasticsearch.go │ │ ├── model_stateless.go │ │ ├── read.go │ │ ├── read_test.go │ │ └── schema.go │ ├── privatelinkdatasource │ │ ├── aws_datasource.go │ │ ├── azure_datasource.go │ │ ├── datasource.go │ │ ├── datasource_test.go │ │ ├── gcp_datasource.go │ │ └── regionPrivateLinkMap.json │ ├── stackdatasource │ │ ├── datasource.go │ │ ├── datasource_test.go │ │ ├── flatteners_apm.go │ │ ├── flatteners_apm_test.go │ │ ├── flatteners_elasticsearch.go │ │ ├── flatteners_elasticsearch_test.go │ │ ├── flatteners_enterprise_search.go │ │ ├── flatteners_enterprise_search_test.go │ │ ├── flatteners_kibana.go │ │ ├── flatteners_kibana_test.go │ │ └── schema.go │ └── trafficfilterdatasource │ │ ├── datasource.go │ │ └── datasource_test.go ├── ecresource │ ├── deploymentresource │ │ ├── apm │ │ │ ├── v1 │ │ │ │ ├── apm.go │ │ │ │ ├── apm_config.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── apm_config.go │ │ │ │ ├── apm_payload.go │ │ │ │ ├── apm_payload_test.go │ │ │ │ ├── apm_read.go │ │ │ │ ├── apm_read_test.go │ │ │ │ ├── apm_topology.go │ │ │ │ └── schema.go │ │ ├── create.go │ │ ├── delete.go │ │ ├── deployment │ │ │ ├── v1 │ │ │ │ ├── deployment.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── deployment_create_payload.go │ │ │ │ ├── deployment_create_payload_test.go │ │ │ │ ├── deployment_parse_credentials_test.go │ │ │ │ ├── deployment_read.go │ │ │ │ ├── deployment_read_test.go │ │ │ │ ├── deployment_test_utils.go │ │ │ │ ├── deployment_update_payload.go │ │ │ │ ├── deployment_update_payload_test.go │ │ │ │ ├── elasticsearch_remote_cluster_payload_test.go │ │ │ │ ├── partial_stapshot_strategy_test.go │ │ │ │ ├── schema.go │ │ │ │ ├── set_unknown_if_reset_password_is_true.go │ │ │ │ ├── traffic_filter_test.go │ │ │ │ ├── use_null_unless_adding_apm_or_integrations_server.go │ │ │ │ ├── use_null_unless_adding_apm_or_integrations_server_test.go │ │ │ │ ├── version_validator.go │ │ │ │ └── version_validator_test.go │ │ ├── deployment_not_found_test.go │ │ ├── deployment_test.go │ │ ├── elasticsearch │ │ │ ├── v1 │ │ │ │ ├── elasticsearch.go │ │ │ │ ├── elasticsearch_config.go │ │ │ │ ├── elasticsearch_extension.go │ │ │ │ ├── elasticsearch_remote_cluster.go │ │ │ │ ├── elasticsearch_snapshot_source.go │ │ │ │ ├── elasticsearch_strategy.go │ │ │ │ ├── elasticsearch_topology.go │ │ │ │ ├── elasticsearch_topology_autoscaling.go │ │ │ │ ├── elasticsearch_topology_config.go │ │ │ │ ├── elasticsearch_trust_account.go │ │ │ │ ├── elasticsearch_trust_external.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── cloud_id_plan_modifier.go │ │ │ │ ├── elasticsearch_config.go │ │ │ │ ├── elasticsearch_config_test.go │ │ │ │ ├── elasticsearch_extension.go │ │ │ │ ├── elasticsearch_keystore_contents.go │ │ │ │ ├── elasticsearch_payload.go │ │ │ │ ├── elasticsearch_payload_test.go │ │ │ │ ├── elasticsearch_read.go │ │ │ │ ├── elasticsearch_read_test.go │ │ │ │ ├── elasticsearch_remote_cluster.go │ │ │ │ ├── elasticsearch_snapshot.go │ │ │ │ ├── elasticsearch_snapshot_source.go │ │ │ │ ├── elasticsearch_test_utils.go │ │ │ │ ├── elasticsearch_topology.go │ │ │ │ ├── elasticsearch_trust_account.go │ │ │ │ ├── elasticsearch_trust_account_test.go │ │ │ │ ├── elasticsearch_trust_external.go │ │ │ │ ├── elasticsearch_trust_external_test.go │ │ │ │ ├── node_roles.go │ │ │ │ ├── node_roles_plan_modifier.go │ │ │ │ ├── node_roles_plan_modifier_test.go │ │ │ │ ├── node_roles_test.go │ │ │ │ ├── node_roles_validator.go │ │ │ │ ├── node_roles_validator_test.go │ │ │ │ ├── node_types_plan_modifier.go │ │ │ │ ├── node_types_plan_modifier_test.go │ │ │ │ ├── node_types_validator.go │ │ │ │ ├── node_types_validator_test.go │ │ │ │ ├── schema.go │ │ │ │ ├── topology_plan_modifier.go │ │ │ │ └── topology_plan_modifier_test.go │ │ ├── enterprisesearch │ │ │ ├── v1 │ │ │ │ ├── enterprise_search.go │ │ │ │ ├── enterprise_search_config.go │ │ │ │ ├── enterprise_search_topology.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── enterprise_search_config.go │ │ │ │ ├── enterprise_search_payload.go │ │ │ │ ├── enterprise_search_payload_test.go │ │ │ │ ├── enterprise_search_read.go │ │ │ │ ├── enterprise_search_read_test.go │ │ │ │ ├── enterprise_search_topology.go │ │ │ │ └── schema.go │ │ ├── integrationsserver │ │ │ ├── v1 │ │ │ │ ├── integrations_server.go │ │ │ │ ├── integrations_server_config.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── integrations_server_config.go │ │ │ │ ├── integrations_server_payload.go │ │ │ │ ├── integrations_server_payload_test.go │ │ │ │ ├── integrations_server_read.go │ │ │ │ ├── integrations_server_read_test.go │ │ │ │ ├── integrations_server_topology.go │ │ │ │ └── schema.go │ │ ├── kibana │ │ │ ├── v1 │ │ │ │ ├── kibana.go │ │ │ │ ├── kibana_config.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── kibana_config.go │ │ │ │ ├── kibana_payload.go │ │ │ │ ├── kibana_payload_test.go │ │ │ │ ├── kibana_read.go │ │ │ │ ├── kibana_read_test.go │ │ │ │ ├── kibana_topology.go │ │ │ │ └── schema.go │ │ ├── observability │ │ │ ├── v1 │ │ │ │ ├── observability.go │ │ │ │ └── schema.go │ │ │ └── v2 │ │ │ │ ├── observability_payload.go │ │ │ │ ├── observability_payload_test.go │ │ │ │ ├── observability_read.go │ │ │ │ ├── observability_read_test.go │ │ │ │ └── schema.go │ │ ├── plan_modifier.go │ │ ├── private_state.go │ │ ├── private_state_test.go │ │ ├── read.go │ │ ├── read_test.go │ │ ├── resource.go │ │ ├── testdata │ │ │ ├── aws-io-optimized-v2-empty-config-create-expected-payload.json │ │ │ ├── aws-io-optimized-v2-empty-config-expected-deployment1.json │ │ │ ├── aws-io-optimized-v2-empty-config-expected-deployment2.json │ │ │ ├── aws-io-optimized-v2-empty-config-expected-deployment3.json │ │ │ ├── aws-io-optimized-v2-template-migration-response.json │ │ │ ├── aws-io-optimized-v2.json │ │ │ ├── deployment-aws-ccs.json │ │ │ ├── deployment-aws-io-optimized-extension.json │ │ │ ├── deployment-aws-io-optimized-tags.json │ │ │ ├── deployment-aws-io-optimized.json │ │ │ ├── deployment-azure-io-optimized.json │ │ │ ├── deployment-gcp-hot-warm-node_roles.json │ │ │ ├── deployment-gcp-hot-warm.json │ │ │ ├── deployment-gcp-io-optimized-autoscale.json │ │ │ ├── deployment-gcp-io-optimized.json │ │ │ ├── deployment-update-aws-cross-cluster-search-v2.json │ │ │ ├── template-aws-cross-cluster-search-v2.json │ │ │ ├── template-aws-hot-warm-v2.json │ │ │ ├── template-aws-io-optimized-v2-ic_version.json │ │ │ ├── template-aws-io-optimized-v2.json │ │ │ ├── template-ece-3.0.0-default.json │ │ │ └── template-empty.json │ │ ├── testutil │ │ │ ├── testutil_func.go │ │ │ └── testutil_func_test.go │ │ ├── topology │ │ │ └── v1 │ │ │ │ └── topology.go │ │ ├── topology_dedicated_masters.go │ │ ├── topology_dedicated_masters_test.go │ │ ├── update.go │ │ ├── update_test.go │ │ ├── utils │ │ │ ├── definitions.go │ │ │ └── missing_field_error.go │ │ └── wait.go │ ├── elasticsearchkeystoreresource │ │ ├── create.go │ │ ├── delete.go │ │ ├── expanders.go │ │ ├── expanders_test.go │ │ ├── read.go │ │ ├── resource_test.go │ │ ├── schema.go │ │ └── update.go │ ├── extensionresource │ │ ├── create.go │ │ ├── delete.go │ │ ├── read.go │ │ ├── resource_test.go │ │ ├── schema.go │ │ ├── testdata │ │ │ └── test_extension_bundle.json │ │ ├── update.go │ │ └── upload.go │ ├── organizationresource │ │ ├── create.go │ │ ├── delete.go │ │ ├── import.go │ │ ├── list_difference.go │ │ ├── list_difference_test.go │ │ ├── mapper_roles.go │ │ ├── mapper_to_api.go │ │ ├── mapper_to_model.go │ │ ├── mapper_to_model_test.go │ │ ├── read.go │ │ ├── resource.go │ │ ├── resource_mock_utils_test.go │ │ ├── resource_test.go │ │ ├── schema.go │ │ └── update.go │ ├── projectresource │ │ ├── create.go │ │ ├── create_test.go │ │ ├── delete.go │ │ ├── delete_test.go │ │ ├── elasticsearch.go │ │ ├── elasticsearch_test.go │ │ ├── mocks.gen.go │ │ ├── observability.go │ │ ├── observability_test.go │ │ ├── read.go │ │ ├── read_test.go │ │ ├── resource.go │ │ ├── resource_test.go │ │ ├── security.go │ │ ├── security_test.go │ │ ├── update.go │ │ └── update_test.go │ ├── snapshotrepositoryresource │ │ ├── create.go │ │ ├── delete.go │ │ ├── read.go │ │ ├── resource_test.go │ │ ├── schema.go │ │ └── update.go │ ├── trafficfilterassocresource │ │ ├── create.go │ │ ├── delete.go │ │ ├── import_state.go │ │ ├── read.go │ │ ├── resource_test.go │ │ ├── schema.go │ │ └── update.go │ └── trafficfilterresource │ │ ├── create.go │ │ ├── delete.go │ │ ├── expanders.go │ │ ├── expanders_test.go │ │ ├── flatteners.go │ │ ├── flatteners_test.go │ │ ├── read.go │ │ ├── resource_test.go │ │ ├── schema.go │ │ ├── testutils.go │ │ └── update.go ├── internal │ ├── converters │ │ ├── convert_tags.go │ │ ├── convert_tags_test.go │ │ ├── extract_endpoint.go │ │ ├── extract_endpoint_test.go │ │ ├── parse_topology_size.go │ │ └── parse_topology_size_test.go │ ├── gen │ │ └── serverless │ │ │ ├── client-config.yaml │ │ │ ├── client.gen.go │ │ │ ├── mocks │ │ │ └── client.gen.go │ │ │ ├── modify_spec.sh │ │ │ ├── oapi-config.yaml │ │ │ ├── provider_ec │ │ │ └── ec_provider_gen.go │ │ │ ├── resource_elasticsearch_project │ │ │ └── elasticsearch_project_resource_gen.go │ │ │ ├── resource_observability_project │ │ │ └── observability_project_resource_gen.go │ │ │ ├── resource_security_project │ │ │ └── security_project_resource_gen.go │ │ │ ├── serverless-project-api-dereferenced.yml │ │ │ ├── serverless.go │ │ │ ├── spec-mod.json │ │ │ ├── spec.json │ │ │ └── string_use_state_for_unknown.json │ ├── planmodifiers │ │ ├── attribute_changed.go │ │ ├── bool_default_value.go │ │ ├── has_attribute.go │ │ ├── set_default_value.go │ │ ├── state_attribute_defined.go │ │ ├── string_default_value.go │ │ ├── use_state_unless_template_changed.go │ │ └── use_state_unless_template_changed_test.go │ ├── provider.go │ ├── util │ │ ├── helpers.go │ │ ├── parsers.go │ │ ├── parsers_test.go │ │ ├── resource_kind.go │ │ ├── testutils.go │ │ ├── traffic_filter_err.go │ │ └── traffic_filter_err_test.go │ └── validators │ │ ├── knownvalidator.go │ │ └── urlvalidator.go ├── provider.go ├── provider_config.go ├── provider_config_test.go ├── provider_test.go ├── requests.log └── version.go ├── examples ├── README.md ├── data-sources │ ├── ec_aws_privatelink_endpoint │ │ └── data-source.tf │ ├── ec_azure_privatelink_endpoint │ │ └── data-source.tf │ ├── ec_deployment │ │ └── data-source.tf │ ├── ec_deployment_templates │ │ └── data-source.tf │ ├── ec_deployments │ │ └── data-source.tf │ ├── ec_gcp_private_service_connect_endpoint │ │ └── data-source.tf │ ├── ec_stack │ │ └── data-source.tf │ └── ec_traffic_filter │ │ └── data-source.tf ├── deployment_ccs │ ├── README.md │ ├── deployment.tf │ └── outputs.tf ├── deployment_ec2_instance │ ├── README.md │ ├── aws_ec2.tf │ ├── elastic_deployment.tf │ ├── provider.tf │ └── variables.tf ├── deployment_with_init │ ├── README.md │ ├── deployment.tf │ ├── es_config.sh │ ├── main.tf │ └── provider.tf ├── extension_bundle │ ├── README.md │ ├── extension.tf │ ├── files │ │ ├── content.json │ │ └── content.json.zip │ └── outputs.tf └── resources │ ├── ec_deployment │ ├── basic │ │ └── deployment.tf │ ├── import.sh │ ├── with-autoscaling │ │ └── deployment.tf │ ├── with-ccs │ │ └── deployment.tf │ ├── with-config │ │ ├── deployment.tf │ │ ├── es.yaml │ │ └── outputs.tf │ ├── with-keystore │ │ └── deployment.tf │ └── with-o11y │ │ └── deployment.tf │ ├── ec_deployment_elasticsearch_keystore │ ├── basic │ │ └── resource.tf │ └── gcs-snapshots │ │ └── resource.tf │ ├── ec_deployment_extension │ ├── import.sh │ ├── with-file │ │ └── resource.tf │ └── with-url │ │ └── resource.tf │ ├── ec_deployment_traffic_filter │ ├── azure │ │ └── resource.tf │ ├── gcp │ │ └── resource.tf │ ├── import.sh │ └── ip │ │ └── resource.tf │ ├── ec_deployment_traffic_filter_association │ └── resource.tf │ ├── ec_elasticsearch_project │ ├── import.sh │ └── resource.tf │ ├── ec_observability_project │ ├── import.sh │ └── resource.tf │ ├── ec_organization │ ├── basic.tf │ └── locals.tf │ ├── ec_security_project │ ├── import.sh │ └── resource.tf │ └── ec_snapshot_repository │ ├── import.sh │ ├── resource-azure.tf │ ├── resource-gcs.tf │ └── resource-s3.tf ├── gen └── gen.go ├── go.mod ├── go.sum ├── main.go ├── renovate.json ├── scripts ├── Makefile.help ├── changelog.tmpl ├── generate-changelog.sh ├── release-note.tmpl ├── retry.sh ├── uname_arch.sh ├── uname_arch_goreleaser.sh ├── update-provider-version.sh └── validate_examples.sh ├── templates ├── data-sources │ ├── aws_privatelink_endpoint.md.tmpl │ ├── azure_privatelink_endpoint.md.tmpl │ ├── deployment.md.tmpl │ ├── deployment_templates.md.tmpl │ ├── deployments.md.tmpl │ ├── gcp_private_service_connect_endpoint.md.tmpl │ ├── stack.md.tmpl │ └── traffic_filter.md.tmpl ├── guides │ └── configuring-sso-ec-deployment.md ├── index.md.tmpl └── resources │ ├── deployment.md.tmpl │ ├── deployment_elasticsearch_keystore.md.tmpl │ ├── deployment_extension.md.tmpl │ ├── deployment_traffic_filter.md.tmpl │ ├── deployment_traffic_filter_association.md.tmpl │ ├── elasticsearch_project.md.tmpl │ ├── observability_project.md.tmpl │ ├── organization.md.tmpl │ ├── security_project.md.tmpl │ └── snapshot_repository.md.tmpl └── tools └── tools.go /.buildkite/acceptance.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | echo "--- Download dependencies" 5 | make vendor 6 | 7 | echo "--- Run acceptance tests" 8 | EC_API_KEY=$TERRAFORM_PROVIDER_API_KEY_SECRET make testacc 9 | -------------------------------------------------------------------------------- /.buildkite/acceptance_pipeline.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - label: ":test_tube: Acceptance tests" 3 | key: "acceptance-tests" 4 | command: .buildkite/acceptance.sh 5 | agents: 6 | image: "docker.io/library/golang:1.24" 7 | cpu: "8" 8 | memory: "4G" 9 | -------------------------------------------------------------------------------- /.buildkite/hooks/pre-command: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | #Mimic Jenkins behavior during the migration 6 | export BUILD_ID=$BUILDKITE_BUILD_ID 7 | 8 | VAULT_PATH=secret/ci/elastic-terraform-provider-ec/terraform-provider-secrets 9 | RELEASE_VAULT_PATH=kv/ci-shared/terraform-providers 10 | 11 | # Secrets must be redacted 12 | # https://buildkite.com/docs/pipelines/managing-log-output#redacted-environment-variables 13 | if [[ "$BUILDKITE_PIPELINE_SLUG" == "terraform-provider-ec-acceptance" ]]; then 14 | export TERRAFORM_PROVIDER_API_KEY_SECRET=$(scripts/retry.sh 5 vault kv get -field apikey ${VAULT_PATH}) 15 | fi 16 | 17 | if [[ "$BUILDKITE_PIPELINE_SLUG" == "terraform-provider-ec-release" ]]; then 18 | export GPG_PRIVATE_SECRET=$(scripts/retry.sh 5 vault kv get -field gpg_private ${RELEASE_VAULT_PATH}) 19 | export GPG_PASSPHRASE_SECRET=$(scripts/retry.sh 5 vault kv get -field gpg_passphrase ${RELEASE_VAULT_PATH}) 20 | export GPG_FINGERPRINT_SECRET=$(scripts/retry.sh 5 vault kv get -field gpg_fingerprint ${RELEASE_VAULT_PATH}) 21 | export GITHUB_TOKEN="${VAULT_GITHUB_TOKEN}" 22 | fi 23 | -------------------------------------------------------------------------------- /.buildkite/hooks/pre-exit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | if [[ "$BUILDKITE_STEP_KEY" == "acceptance-tests" ]]; then 6 | echo "--- Sweeps any deployments older than 1h." 7 | EC_API_KEY=$TERRAFORM_PROVIDER_API_KEY_SECRET SWEEPARGS=-sweep-run=ec_deployments make sweep 8 | rm -rf reports bin 9 | fi 10 | -------------------------------------------------------------------------------- /.buildkite/pull-requests.json: -------------------------------------------------------------------------------- 1 | { 2 | "jobs": [ 3 | { 4 | "enabled": true, 5 | "pipeline_slug": "terraform-provider-ec-acceptance", 6 | "allow_org_users": true, 7 | "allowed_repo_permissions": ["admin", "write"], 8 | "allowed_list": ["renovate[bot]"], 9 | "set_commit_status": true, 10 | "build_on_commit": true, 11 | "build_on_comment": true, 12 | "trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))", 13 | "always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))", 14 | "skip_ci_labels": [ ], 15 | "skip_target_branches": [ ], 16 | "skip_ci_on_only_changed": [ 17 | "^docs/", 18 | "^developer_docs/" 19 | ], 20 | "always_require_ci_on_changed": [ ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.buildkite/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | echo "--- Importing GPG key" 5 | echo -n "$GPG_PRIVATE_SECRET" | base64 --decode | gpg --import --batch --yes --passphrase "$GPG_PASSPHRASE_SECRET" 6 | 7 | echo "--- Caching GPG passphrase" 8 | echo "$GPG_PASSPHRASE_SECRET" | gpg --armor --detach-sign --passphrase-fd 0 --pinentry-mode loopback 9 | 10 | echo "--- Installing jq" 11 | apt-get update 12 | apt-get install jq -y 13 | 14 | echo "--- Release the binaries" 15 | make release 16 | -------------------------------------------------------------------------------- /.buildkite/release_pipeline.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - label: ":rocket: Release" 3 | command: .buildkite/release.sh 4 | agents: 5 | image: "docker.io/library/golang:1.24" 6 | cpu: "8" 7 | memory: "4G" 8 | -------------------------------------------------------------------------------- /.changelog/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/terraform-provider-ec/9507fdf3e2b13b64d0db488b420cadc12be8f195/.changelog/.gitkeep -------------------------------------------------------------------------------- /.changelog/814.txt: -------------------------------------------------------------------------------- 1 | ```release-note:feature 2 | resource/deployment: Automatically add a dedicated master tier when it is required due to the number of nodes in the cluster. Also removes it again if the number of nodes drops below the threshold for a dedicated master tier. 3 | This does not affect configurations that have explicitly configured a master tier. 4 | ``` 5 | -------------------------------------------------------------------------------- /.changelog/817.txt: -------------------------------------------------------------------------------- 1 | ```release-note:feature 2 | resource/project: Adds `elasticsearch_project`, `observability_project`, and `security_project` resources to manage Serverless projects. 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/820.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | resource/deployment: Fixes a bug where a validation would fail when using a dynamic stack version (e.g. `data.ec_stack.latest.version`) 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/821.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | resource/deployment: Correctly handle deployment-alias being set to empty value. Setting an empty value should remove the alias instead of ignoring the change. 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/823.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | datasource/gcp_private_service_connect_endpoint: Fixup incorrect reference data for northamerica-northeast1. 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/855.txt: -------------------------------------------------------------------------------- 1 | ```release-note:feature 2 | resource/organization: Allows managing the members of an organization: They can now be invited to the organization (and later removed) and their assigned roles can be updated. 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/858.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | resource/deployment: Avoid overriding snapshot settings with every update. The snapshot settings are now only updated if they are actually set in the terraform config. This allows managing the snapshot lifecycle policy with the elasticstack provider instead of the ec provider. 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/859.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | resource/deployment: Avoid sending an update for trust settings if they have not changed. 3 | ``` -------------------------------------------------------------------------------- /.changelog/860.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | datasource/gcp_private_service_connect_endpoint: Add missing regions. 3 | ``` 4 | -------------------------------------------------------------------------------- /.changelog/869.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | provider: Remove validators.Known() for the provider endpoint. 3 | ``` -------------------------------------------------------------------------------- /.changelog/878.txt: -------------------------------------------------------------------------------- 1 | ```release-note:bug 2 | resource/deployment: Don't use nil state for a computed attribute. 3 | ``` 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in 2 | # the repository. 3 | * @elastic/control-plane-hosted-applications 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | ## Description 12 | 13 | 14 | 15 | ## Your Environment 16 | 17 | 18 | * Version used: 19 | * Environment name and version (e.g. Go 1.9): 20 | * Server type and version: 21 | * Operating System and version: 22 | * Link to your project: 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/GENERIC_QUESTION.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Generic Question 3 | about: Not a Bug Report or a Feature Request? Ask a question. 4 | labels: Team:Delivery, question 5 | 6 | --- 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Question 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/workflows/comment-on-asciidoc-changes.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Comment on PR for .asciidoc changes 3 | 4 | on: 5 | # We need to use pull_request_target to be able to comment on PRs from forks 6 | pull_request_target: 7 | types: 8 | - synchronize 9 | - opened 10 | - reopened 11 | branches: 12 | - main 13 | - master 14 | - "9.0" 15 | 16 | jobs: 17 | comment-on-asciidoc-change: 18 | permissions: 19 | contents: read 20 | pull-requests: write 21 | uses: elastic/docs-builder/.github/workflows/comment-on-asciidoc-changes.yml@main 22 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | # Unit test run 7 | unit: 8 | name: Unit 9 | runs-on: ubuntu-latest 10 | steps: 11 | 12 | - name: Set up Go 13 | uses: actions/setup-go@v5 14 | with: 15 | go-version: 1.22 16 | id: go 17 | 18 | - name: Check out code into the Go module directory 19 | uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 20 | 21 | - name: Install terraform 22 | uses: hashicorp/setup-terraform@v3 23 | with: 24 | terraform_version: "1.x.x" 25 | terraform_wrapper: false 26 | 27 | - name: Cache Go Modules 28 | uses: actions/cache@v4 29 | with: 30 | path: ~/go/pkg/mod 31 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} 32 | restore-keys: | 33 | ${{ runner.os }}-go- 34 | 35 | - name: Get dependencies 36 | run: make vendor 37 | id: modules 38 | 39 | - name: Linters 40 | run: make lint 41 | id: lint 42 | 43 | - name: Run unit tests 44 | run: make unit 45 | id: unit 46 | 47 | - name: Validate the examples 48 | run: make install validate-examples 49 | id: validate-examples 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | reports 3 | .terraform 4 | examples/*/.terraform.tfstate.lock.info 5 | examples/*/*.log 6 | examples/*/*.tfstate 7 | examples/*/*.tfstate.backup 8 | .vscode 9 | .idea 10 | .apikey 11 | dist 12 | .ci/.gpg_* 13 | .ci/.github_* 14 | .terraform.lock.hcl -------------------------------------------------------------------------------- /.golangci.yaml: -------------------------------------------------------------------------------- 1 | linters: 2 | disable-all: true 3 | enable: 4 | - errcheck 5 | - gofmt 6 | - gosimple 7 | - ineffassign 8 | - misspell 9 | - staticcheck 10 | - unconvert 11 | - unused 12 | - vet 13 | 14 | linters-settings: 15 | errcheck: 16 | ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close 17 | 18 | run: 19 | timeout: 10m 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | export GO111MODULE ?= on 3 | export VERSION := 0.12.2-dev 4 | export BINARY := terraform-provider-ec 5 | export GOBIN = $(shell pwd)/bin 6 | 7 | include scripts/Makefile.help 8 | .DEFAULT_GOAL := help 9 | 10 | include build/Makefile.build 11 | include build/Makefile.test 12 | include build/Makefile.dev 13 | include build/Makefile.deps 14 | include build/Makefile.tools 15 | include build/Makefile.lint 16 | include build/Makefile.format 17 | include build/Makefile.release 18 | include build/Makefile.version 19 | -------------------------------------------------------------------------------- /build/Makefile.build: -------------------------------------------------------------------------------- 1 | BINARY_LOCATION ?= bin/$(BINARY) 2 | PLUGIN_LOCATION ?= ~/.terraform.d/plugins 3 | OS = $(shell uname -s|tr '[:upper:]' '[:lower:]') 4 | ARCH = $(shell uname -m) 5 | STRIPPED_V ?= $(subst -dev,,$(VERSION)) 6 | PLUGIN_0.13 = registry.terraform.io/elastic/ec/$(STRIPPED_V)/$(OS)_$(ARCH)/terraform-provider-ec_v$(STRIPPED_V) 7 | 8 | ### Build targets 9 | 10 | ## Generates the required files for the builds. (Auto-run by build). 11 | .PHONY: gen 12 | gen: 13 | @ echo "-> Generating files..." 14 | @ go generate ./... 15 | @ $(MAKE) license-header 16 | 17 | generate: gen 18 | 19 | ## Builds the source code and saves the binary to bin/terraform-provider-ec. 20 | .PHONY: build 21 | build: gen 22 | @ echo "-> Building binary with GCFLAGS=$(GCFLAGS) in $(BINARY_LOCATION)..." 23 | @ go build $(GCFLAGS) -o $(BINARY_LOCATION) . 24 | 25 | ## Builds the source code and moves the binary to the user's terraform plugin location. 26 | .PHONY: install 27 | install: build 28 | @ mkdir -p $(PLUGIN_LOCATION) 29 | @ cp $(BINARY_LOCATION) $(PLUGIN_LOCATION) 30 | @ mkdir -p $(shell dirname $(PLUGIN_LOCATION)/$(PLUGIN_0.13)) 31 | @ cp $(BINARY_LOCATION) $(PLUGIN_LOCATION)/$(PLUGIN_0.13) 32 | @ echo "-> Copied terraform provider to $(PLUGIN_LOCATION)/$(PLUGIN_0.13)" 33 | 34 | ## Generate Terraform docs 35 | .PHONY: docs-generate 36 | docs-generate: tools ## Generate documentation for the provider 37 | @ $(GOBIN)/tfplugindocs 38 | -------------------------------------------------------------------------------- /build/Makefile.dev: -------------------------------------------------------------------------------- 1 | ### Development targets 2 | 3 | ## Downlaods all the Golang dependencies and generates the NOTICE file. 4 | vendor: $(GOBIN)/go-licenser 5 | @ echo "-> Downloading project imports..." 6 | @ go mod download 7 | @ go mod tidy 8 | @ $(GOBIN)/go-licenser -license ASL2 -notice 9 | 10 | ## Removes the versioned cloud-sdk-go and uses the local copy (assumed to be in ../cloud-sdk-go). 11 | .PHONY: fake-sdk 12 | fake-sdk: 13 | @ go mod edit -replace=github.com/elastic/cloud-sdk-go=../cloud-sdk-go 14 | 15 | ## Removes fake cloud-sdk-go. 16 | .PHONY: remove-fake-sdk 17 | remove-fake-sdk: 18 | @ go mod edit -dropreplace=github.com/elastic/cloud-sdk-go 19 | -------------------------------------------------------------------------------- /build/Makefile.format: -------------------------------------------------------------------------------- 1 | ## Formats the all Go files to the desired format. 2 | .PHONY: format 3 | format: deps tools 4 | @ echo "-> Formatting Go files..." 5 | @ $(MAKE) license-header 6 | @ $(GOBIN)/golangci-lint run --fix 7 | @ $(GOBIN)/tfproviderlint -fix ./... 8 | @ echo "-> Formatting Terraform documentation blocks..." 9 | @ find ./docs -type f -name "*.md" -exec $(GOBIN)/terrafmt fmt -f {} \; 10 | @ terraform fmt -write=true -recursive 11 | @ echo "-> Done." 12 | 13 | .PHONY: license-header 14 | license-header: deps 15 | @ $(GOBIN)/go-licenser -license ASL2 16 | -------------------------------------------------------------------------------- /build/Makefile.lint: -------------------------------------------------------------------------------- 1 | ## Lints all of the source files 2 | .PHONY: lint 3 | lint: golangci-lint check-license tfproviderlint tfproviderdocs terrafmt fmt 4 | 5 | .PHONY: tfproviderlint 6 | tfproviderlint: tools 7 | @ echo '-> Ignoring tfproviderlint until https://github.com/bflad/tfproviderlint/issues/255 is fixed...' 8 | #@ echo "-> Checking source code against terraform provider linters..." 9 | #@ $(GOBIN)/tfproviderlint ./... 10 | 11 | .PHONY: tfproviderdocs 12 | tfproviderdocs: tools 13 | @ echo "-> Running terraform provider docs check..." 14 | @ $(GOBIN)/tfproviderdocs check -provider-name $(BINARY) . 15 | 16 | .PHONY: check-license 17 | check-license: deps 18 | @ echo "-> Running license check..." 19 | @ $(GOBIN)/go-licenser -license ASL2 -d . 20 | 21 | .PHONY: golangci-lint 22 | golangci-lint: deps 23 | @ echo "-> Running golangci-lint..." 24 | @ $(GOBIN)/golangci-lint run 25 | 26 | .PHONY: terrafmt 27 | terrafmt: 28 | @ echo "-> Checking that the terraform docs codeblocks are formatted..." 29 | @ find ./docs -type f -name "*.md" -exec $(GOBIN)/terrafmt diff -c -q {} \; 30 | 31 | ## Validates all the terraform example files found in examples/ 32 | validate-examples: 33 | @ ./scripts/validate_examples.sh 34 | 35 | ## Formats all the terraform ".tf" files in the repository 36 | fmt: 37 | @ echo "-> Checking that the terraform .tf files are formatted..." 38 | @ terraform fmt -write=false -recursive -check 39 | -------------------------------------------------------------------------------- /build/Makefile.release: -------------------------------------------------------------------------------- 1 | OWNER = elastic 2 | REPO = terraform-provider-ec 3 | PREFIXED_V = v$(subst -dev,,$(VERSION)) 4 | 5 | ### Release targets 6 | 7 | ## Tags the current commit as the release commit with $(VERSION) (minus -dev). 8 | tag: 9 | @ git fetch 10 | ifeq ($(shell git tag -l $(PREFIXED_V)),$(PREFIXED_V)) 11 | @ echo "-> git tag $(PREFIXED_V) already exists, exiting..." 12 | @ exit 1 13 | endif 14 | ifeq ($(shell git remote -v | grep $(OWNER)/$(REPO)),) 15 | @ echo "-> git remote 'upstream' is not configured, exiting..." 16 | @ exit 2 17 | endif 18 | @ $(eval REMOTE = $(shell git remote -v | grep $(OWNER)/$(REPO)| head -1 | awk '{print $$1}')) 19 | @ echo "Pushing git tag $(PREFIXED_V) to remote \"$(REMOTE)\"..." 20 | @ git tag $(PREFIXED_V) 21 | @ git push -u $(REMOTE) $(PREFIXED_V) 22 | 23 | ## Creates a snapshot build of the terraform provider. 24 | snapshot: $(GOBIN)/goreleaser 25 | @ $(GOBIN)/goreleaser --clean --snapshot --skip-validate 26 | 27 | ## Releases a new version of the terraform provider with a matching tag. 28 | release: $(GOBIN)/goreleaser 29 | @ $(MAKE) gen VERSION=$(subst -dev,,$(VERSION)) 30 | @ $(GOBIN)/goreleaser --clean --skip-validate --parallelism=4 31 | 32 | ## Builds a new version of the terraform provider with a matching tag without publishing it. 33 | release-no-publish: $(GOBIN)/goreleaser 34 | @ $(MAKE) gen VERSION=$(subst -dev,,$(VERSION)) 35 | @ $(GOBIN)/goreleaser --clean --skip-validate --skip-publish --parallelism=4 36 | 37 | .PHONY: changelog 38 | changelog: $(GOBIN)/changelog-build 39 | @ echo "-> Generating changelog..." 40 | @ ./scripts/generate-changelog.sh 41 | -------------------------------------------------------------------------------- /build/Makefile.test: -------------------------------------------------------------------------------- 1 | SWEEP ?=us-east-1 2 | SWEEP_DIR ?= $(TEST_ACC) 3 | SWEEP_CI_RUN_FILTER ?= ec_deployments 4 | TEST ?= ./... 5 | TEST_COUNT ?= 1 6 | TESTUNITARGS ?= -timeout 10m -race -cover -coverprofile=reports/c.out 7 | TEST_ACC ?= github.com/elastic/terraform-provider-ec/ec/acc 8 | TEST_NAME ?= TestAcc 9 | TEST_ACC_PARALLEL = 6 10 | 11 | REPORT_PATH ?= ./reports 12 | 13 | ### Test targets 14 | 15 | .PHONY: _report_path 16 | _report_path: 17 | @ mkdir -p $(REPORT_PATH) 18 | 19 | ## Runs unit tests. Use TESTARGS and TEST to control which flags and packages are used and tested. 20 | .PHONY: unit 21 | unit: _report_path 22 | @ echo "-> Running unit tests for $(BINARY)..." 23 | @ go test $(TEST) $(TESTARGS) $(TESTUNITARGS) 24 | 25 | ## Alias to "unit". 26 | tests: unit 27 | 28 | .PHONY: testacc 29 | ## Runs the Terraform acceptance tests. Use TEST_NAME, TESTARGS, TEST_COUNT to control execution. 30 | testacc: 31 | @ echo "-> Running terraform acceptance tests..." 32 | @ TF_ACC=1 go test $(TEST_ACC) -v -count $(TEST_COUNT) -parallel $(TEST_ACC_PARALLEL) $(TESTARGS) -timeout 120m -run $(TEST_NAME) 33 | 34 | .PHONY: sweep 35 | ## Destroys any dangling infrastructure created by the acceptance tests (terraform_acc_ prefix). 36 | sweep: 37 | ifndef BUILD_ID 38 | @ echo "-> WARNING: This will destroy infrastructure. Use only in development accounts." 39 | @ read -r -p "do you wish to continue? [y/N]: " res && if [[ "$${res:0:1}" =~ ^([yY]) ]]; then echo "-> Continuing..."; else exit 1; fi 40 | endif 41 | @ go test $(SWEEP_DIR) -v -sweep=$(SWEEP) $(SWEEPARGS) -timeout 60m 42 | -------------------------------------------------------------------------------- /build/Makefile.tools: -------------------------------------------------------------------------------- 1 | 2 | VERSION_TFPROVIDERDOCS:=v0.6.0 3 | VERSION_TERRAFMT:=v0.5.2 4 | VERSION_TFPROVIDERLINT:=v0.28.1 5 | 6 | ## Installs the required static checks for terraform. 7 | tools: $(GOBIN)/tfproviderdocs $(GOBIN)/terrafmt $(GOBIN)/tfproviderlint $(GOBIN)/tfplugindocs 8 | 9 | 10 | $(VERSION_DIR)/.version-tfproviderdocs-$(VERSION_TFPROVIDERDOCS): | $(VERSION_DIR) 11 | @ rm -f $(VERSION_DIR)/.version-tfproviderdocs-* 12 | @ echo $(VERSION_TFPROVIDERDOCS) > $(VERSION_DIR)/.version-tfproviderdocs-$(VERSION_TFPROVIDERDOCS) 13 | 14 | $(GOBIN)/tfproviderdocs: $(VERSION_DIR)/.version-tfproviderdocs-$(VERSION_TFPROVIDERDOCS) | $(GOBIN) 15 | @ echo "-> Installing tfproviderdocs..." 16 | @ go install github.com/bflad/tfproviderdocs@$(VERSION_TFPROVIDERDOCS) 17 | 18 | 19 | $(VERSION_DIR)/.version-terrafmt-$(VERSION_TERRAFMT): | $(VERSION_DIR) 20 | @ rm -f $(VERSION_DIR)/.version-terrafmt-* 21 | @ echo $(VERSION_TERRAFMT) > $(VERSION_DIR)/.version-terrafmt-$(VERSION_TERRAFMT) 22 | 23 | $(GOBIN)/terrafmt: $(VERSION_DIR)/.version-terrafmt-$(VERSION_TERRAFMT) | $(GOBIN) 24 | @ echo "-> Installing terrafmt..." 25 | @ go install github.com/katbyte/terrafmt@$(VERSION_TERRAFMT) 26 | 27 | 28 | $(VERSION_DIR)/.version-tfproviderlint-$(VERSION_TFPROVIDERLINT): | $(VERSION_DIR) 29 | @ rm -f $(VERSION_DIR)/.version-tfproviderlint-* 30 | @ echo $(VERSION_TFPROVIDERLINT) > $(VERSION_DIR)/.version-tfproviderlint-$(VERSION_TFPROVIDERLINT) 31 | 32 | $(GOBIN)/tfproviderlint: $(VERSION_DIR)/.version-tfproviderlint-$(VERSION_TFPROVIDERLINT) | $(GOBIN) 33 | @ echo "-> Installing tfproviderlint..." 34 | @ go install github.com/bflad/tfproviderlint/cmd/tfproviderlint@$(VERSION_TFPROVIDERLINT) 35 | -------------------------------------------------------------------------------- /build/Makefile.version: -------------------------------------------------------------------------------- 1 | ### Manage repository versions 2 | 3 | CURRENT_VERSION=$$($(GOBIN)/versionbump list Makefile) 4 | 5 | ## Bump the major version for the Terraform Provider for Elastic Cloud. 6 | major: $(GOBIN)/versionbump 7 | @ $(GOBIN)/versionbump -c major Makefile 8 | @ ./scripts/update-provider-version.sh $(CURRENT_VERSION) 9 | 10 | ## Bump the minor o feature version for the Terraform Provider for Elastic Cloud. 11 | minor: $(GOBIN)/versionbump 12 | @ $(GOBIN)/versionbump -c minor Makefile 13 | @ ./scripts/update-provider-version.sh $(CURRENT_VERSION) 14 | 15 | ## Bump the patch o bugfix version for the Terraform Provider for Elastic Cloud. 16 | patch: $(GOBIN)/versionbump 17 | @ $(GOBIN)/versionbump -c patch Makefile 18 | @ ./scripts/update-provider-version.sh $(CURRENT_VERSION) 19 | -------------------------------------------------------------------------------- /docs-elastic/index.asciidoc: -------------------------------------------------------------------------------- 1 | = Elastic Cloud Terraform Documentation 2 | :n: Elastic Cloud Terraform provider 3 | :p: tpec 4 | 5 | The {n} allows you to provision Elastic Cloud deployments on any Elastic Cloud platform, whether it’s Elasticsearch Service or Elastic Cloud Enterprise. 6 | 7 | The provider lets you manage Elastic Cloud deployments as code, and introduce DevOps-driven methodologies to manage and deploy the Elastic Stack and solutions. 8 | 9 | To get started, see our link:https://registry.terraform.io/providers/elastic/ec/latest/docs[Elastic Cloud Terraform provider documentation]. 10 | -------------------------------------------------------------------------------- /docs/data-sources/aws_privatelink_endpoint.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: ec_aws_privatelink_endpoint Data Source" 3 | description: |- 4 | Use this data source to retrieve information about the AWS Private Link configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-vpc.html). 5 | --- 6 | 7 | # Data Source: ec_aws_privatelink_endpoint 8 | 9 | Use this data source to retrieve information about the AWS Private Link configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-vpc.html). 10 | 11 | ## Example Usage 12 | 13 | ```terraform 14 | data "ec_aws_privatelink_endpoint" "us-east-1" { 15 | region = "us-east-1" 16 | } 17 | ``` 18 | 19 | 20 | ## Schema 21 | 22 | ### Required 23 | 24 | - `region` (String) Region to retrieve the Private Link configuration for. 25 | 26 | ### Read-Only 27 | 28 | - `domain_name` (String) The domain name to used in when configuring a private hosted zone in the VPCE connection. 29 | - `vpc_service_name` (String) The VPC service name used to connect to the region. 30 | - `zone_ids` (List of String) The IDs of the availability zones hosting the VPC endpoints. 31 | -------------------------------------------------------------------------------- /docs/data-sources/azure_privatelink_endpoint.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: ec_azure_privatelink_endpoint Data Source" 3 | description: |- 4 | Use this data source to retrieve information about the Azure Private Link configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-vnet.html). 5 | --- 6 | 7 | # Data Source: ec_azure_privatelink_endpoint 8 | 9 | Use this data source to retrieve information about the Azure Private Link configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-vnet.html). 10 | 11 | ## Example Usage 12 | 13 | ```terraform 14 | data "ec_azure_privatelink_endpoint" "eastus" { 15 | region = "eastus" 16 | } 17 | ``` 18 | 19 | 20 | ## Schema 21 | 22 | ### Required 23 | 24 | - `region` (String) Region to retrieve the Private Link configuration for. 25 | 26 | ### Read-Only 27 | 28 | - `domain_name` (String) The domain name to used in when configuring a private hosted zone in the VNet connection. 29 | - `service_alias` (String) The service alias to establish a connection to. 30 | -------------------------------------------------------------------------------- /docs/data-sources/gcp_private_service_connect_endpoint.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: ec_gcp_private_service_connect_endpoint Data Source" 3 | description: |- 4 | Use this data source to retrieve information about the GCP Private Service Connect configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-psc.html). 5 | --- 6 | 7 | # Data Source: ec_gcp_private_service_connect_endpoint 8 | 9 | Use this data source to retrieve information about the GCP Private Service Connect configuration for a given region. Further documentation on how to establish a PrivateLink connection can be found in the ESS [documentation](https://www.elastic.co/guide/en/cloud/current/ec-traffic-filtering-psc.html). 10 | 11 | ## Example Usage 12 | 13 | ```terraform 14 | data "ec_gcp_private_service_connect_endpoint" "us-central1" { 15 | region = "us-central1" 16 | } 17 | ``` 18 | 19 | 20 | ## Schema 21 | 22 | ### Required 23 | 24 | - `region` (String) Region to retrieve the Prive Link configuration for. 25 | 26 | ### Read-Only 27 | 28 | - `domain_name` (String) The domain name to point towards the PSC endpoint. 29 | - `service_attachment_uri` (String) The service attachment URI to attach the PSC endpoint to. 30 | -------------------------------------------------------------------------------- /docs/resources/deployment_traffic_filter_association.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: ec_deployment_traffic_filter_association Resource" 3 | description: |- 4 | Provides an Elastic Cloud traffic filter association resource, which allows traffic filter rules to be associated to an Elastic Cloud deployment outside of the control of Terraform. Associations can be created and deleted. 5 | --- 6 | 7 | # Resource: ec_deployment_traffic_filter_association 8 | 9 | Provides an Elastic Cloud traffic filter association resource, which allows traffic filter rules to be associated to an Elastic Cloud deployment outside of the control of Terraform. Associations can be created and deleted. 10 | 11 | ## Example Usage 12 | 13 | ```terraform 14 | data "ec_deployment" "example" { 15 | id = "320b7b540dfc967a7a649c18e2fce4ed" 16 | } 17 | 18 | resource "ec_deployment_traffic_filter" "example" { 19 | name = "my traffic filter name" 20 | region = "us-east-1" 21 | type = "ip" 22 | 23 | rule { 24 | source = "0.0.0.0/0" 25 | } 26 | } 27 | 28 | resource "ec_deployment_traffic_filter_association" "example" { 29 | traffic_filter_id = ec_deployment_traffic_filter.example.id 30 | deployment_id = ec_deployment.example.id 31 | } 32 | ``` 33 | 34 | 35 | ## Schema 36 | 37 | ### Required 38 | 39 | - `deployment_id` (String) Required deployment ID where the traffic filter will be associated 40 | - `traffic_filter_id` (String) Required traffic filter ruleset ID to tie to a deployment 41 | 42 | ### Read-Only 43 | 44 | - `id` (String) Unique identifier of this resource. 45 | 46 | ## Import 47 | 48 | Import is not supported on this resource 49 | -------------------------------------------------------------------------------- /ec/acc/deployment_extension_destroy_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package acc 19 | 20 | import ( 21 | "fmt" 22 | 23 | "github.com/hashicorp/terraform-plugin-testing/terraform" 24 | 25 | "github.com/elastic/cloud-sdk-go/pkg/api/apierror" 26 | "github.com/elastic/cloud-sdk-go/pkg/client/extensions" 27 | ) 28 | 29 | func testAccExtensionDestroy(s *terraform.State) error { 30 | client, err := newAPI() 31 | if err != nil { 32 | return err 33 | } 34 | 35 | for _, rs := range s.RootModule().Resources { 36 | if rs.Type != "ec_deployment_extension" { 37 | continue 38 | } 39 | 40 | res, err := client.V1API.Extensions.GetExtension( 41 | extensions.NewGetExtensionParams().WithExtensionID(rs.Primary.ID), 42 | client.AuthWriter) 43 | 44 | // If not extension exists, api gets 403 error 45 | if err != nil && apierror.IsRuntimeStatusCode(err, 403) { 46 | continue 47 | } 48 | 49 | return fmt.Errorf("extension (%s) still exists", *res.Payload.ID) 50 | } 51 | 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /ec/acc/deployment_fixture_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package acc 19 | 20 | import ( 21 | "fmt" 22 | "os" 23 | "testing" 24 | ) 25 | 26 | // fixtureDeploymentDefaults takes the default region and default deployment template 27 | // It assumes that the template order is region = %s and deployment_template = %s 28 | func fixtureDeploymentDefaults(t *testing.T, fileName string) string { 29 | t.Helper() 30 | requiresAPIConn(t) 31 | 32 | region := getRegion() 33 | deploymentTpl := setDefaultTemplate(region, defaultTemplate) 34 | 35 | b, err := os.ReadFile(fileName) 36 | if err != nil { 37 | t.Fatal(err) 38 | } 39 | return fmt.Sprintf(string(b), region, deploymentTpl) 40 | } 41 | -------------------------------------------------------------------------------- /ec/acc/deployment_traffic_filter_checks_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package acc 19 | 20 | import ( 21 | "fmt" 22 | 23 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 24 | "github.com/hashicorp/terraform-plugin-testing/terraform" 25 | 26 | "github.com/elastic/cloud-sdk-go/pkg/api" 27 | "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" 28 | ) 29 | 30 | func testAccCheckDeploymentTrafficFilterExists(name string) resource.TestCheckFunc { 31 | return func(s *terraform.State) error { 32 | saved, ok := s.RootModule().Resources[name] 33 | if !ok { 34 | return fmt.Errorf("no deployment resource: %s", name) 35 | } 36 | 37 | if saved.Primary.ID == "" { 38 | return fmt.Errorf("no deployment id is set") 39 | } 40 | client, err := newAPI() 41 | if err != nil { 42 | return err 43 | } 44 | 45 | return api.ReturnErrOnly(trafficfilterapi.Get( 46 | trafficfilterapi.GetParams{ 47 | API: client, 48 | ID: saved.Primary.ID, 49 | }, 50 | )) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ec/acc/sweep_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package acc 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 24 | ) 25 | 26 | func TestMain(m *testing.M) { 27 | resource.TestMain(m) 28 | } 29 | -------------------------------------------------------------------------------- /ec/acc/testdata/datasource_deploymenttemplates.tf: -------------------------------------------------------------------------------- 1 | data "ec_deployment_templates" "test" { 2 | region = "%s" 3 | stack_version = "7.17.0" 4 | } 5 | 6 | data "ec_deployment_templates" "by_id" { 7 | region = "%s" 8 | id = data.ec_deployment_templates.test.templates.0.id 9 | } -------------------------------------------------------------------------------- /ec/acc/testdata/datasource_stack_latest.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | lock = true 4 | region = "%s" 5 | } -------------------------------------------------------------------------------- /ec/acc/testdata/datasource_stack_regex.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "regex" { 2 | version_regex = "8.4.?" 3 | region = "%s" 4 | } -------------------------------------------------------------------------------- /ec/acc/testdata/datasource_tags.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tags" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | tags = { 12 | "foo" = "bar" 13 | "bar" = "baz" 14 | "test_id" = "%s" 15 | } 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | zone_count = 1 21 | autoscaling = {} 22 | } 23 | } 24 | } 25 | 26 | data "ec_deployment" "tagdata" { 27 | id = ec_deployment.tags.id 28 | } 29 | 30 | data "ec_deployments" "tagfilter" { 31 | tags = { 32 | "test_id" = "%s" 33 | } 34 | } -------------------------------------------------------------------------------- /ec/acc/testdata/datasource_trafficfilter.tf: -------------------------------------------------------------------------------- 1 | resource "ec_deployment_traffic_filter" "basic" { 2 | name = "%s" 3 | region = "%s" 4 | type = "ip" 5 | 6 | rule { 7 | source = "0.0.0.0/0" 8 | } 9 | } 10 | 11 | data "ec_traffic_filter" "name" { 12 | id = ec_deployment_traffic_filter.basic.id 13 | } 14 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_autoscale_ml.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "autoscale_ml" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | tags = { 12 | "foo" = "bar" 13 | "bar" = "baz" 14 | "test_id" = "%s" 15 | } 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | zone_count = 1 21 | autoscaling = {} 22 | } 23 | ml = { 24 | autoscaling = { 25 | autoscale = true 26 | } 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_autoscale_ml_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "autoscale_ml" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | tags = { 12 | "foo" = "bar" 13 | "bar" = "baz" 14 | "test_id" = "%s" 15 | } 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | zone_count = 1 21 | autoscaling = {} 22 | } 23 | ml = { 24 | autoscaling = { 25 | autoscale = false 26 | } 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_autoscaling_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "autoscaling" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "autoscaling" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.autoscaling.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | autoscale = "true" 14 | 15 | cold = { 16 | size = "0g" 17 | zone_count = 1 18 | autoscaling = {} 19 | } 20 | 21 | frozen = { 22 | size = "0g" 23 | zone_count = 1 24 | autoscaling = {} 25 | } 26 | 27 | hot = { 28 | size = "1g" 29 | zone_count = 1 30 | autoscaling = { 31 | max_size = "8g" 32 | } 33 | } 34 | 35 | ml = { 36 | size = "1g" 37 | zone_count = 1 38 | autoscaling = { 39 | min_size = "1g" 40 | max_size = "4g" 41 | } 42 | } 43 | 44 | warm = { 45 | size = "2g" 46 | zone_count = 1 47 | autoscaling = { 48 | max_size = "15g" 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_autoscaling_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "autoscaling" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "autoscaling" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.autoscaling.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | autoscale = "false" 14 | 15 | cold = { 16 | size = "0g" 17 | zone_count = 1 18 | autoscaling = {} 19 | } 20 | 21 | frozen = { 22 | size = "0g" 23 | zone_count = 1 24 | autoscaling = {} 25 | } 26 | 27 | hot = { 28 | size = "1g" 29 | zone_count = 1 30 | autoscaling = { 31 | max_size = "8g" 32 | } 33 | } 34 | 35 | ml = { 36 | size = "0g" 37 | zone_count = 1 38 | autoscaling = { 39 | min_size = "0g" 40 | max_size = "4g" 41 | } 42 | } 43 | 44 | warm = { 45 | size = "2g" 46 | zone_count = 1 47 | autoscaling = { 48 | max_size = "15g" 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | alias = "%s" 8 | name = "%s" 9 | region = "%s" 10 | version = data.ec_stack.latest.version 11 | deployment_template_id = "%s" 12 | 13 | elasticsearch = { 14 | hot = { 15 | size = "1g" 16 | autoscaling = {} 17 | } 18 | } 19 | 20 | kibana = { 21 | instance_configuration_id = "%s" 22 | } 23 | 24 | apm = { 25 | instance_configuration_id = "%s" 26 | } 27 | 28 | enterprise_search = { 29 | instance_configuration_id = "%s" 30 | } 31 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_defaults_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "defaults" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | 20 | enterprise_search = { 21 | zone_count = 1 22 | } 23 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_defaults_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "defaults" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | 17 | strategy = "rolling_all" 18 | } 19 | 20 | kibana = { 21 | size = "2g" 22 | } 23 | 24 | integrations_server = { 25 | size = "2g" 26 | } 27 | 28 | enterprise_search = { 29 | zone_count = 1 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_defaults_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "defaults" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | 18 | strategy = "grow_and_shrink" 19 | } 20 | 21 | kibana = {} 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_defaults_hw_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "defaults" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | integrations_server = {} 22 | 23 | enterprise_search = {} 24 | } 25 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_defaults_hw_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "defaults" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "4g" 15 | autoscaling = {} 16 | } 17 | warm = { 18 | size = "4g" 19 | autoscaling = {} 20 | } 21 | } 22 | 23 | kibana = {} 24 | } 25 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_integrations_server_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | 20 | integrations_server = {} 21 | 22 | } 23 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_integrations_server_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | 20 | integrations_server = { 21 | zone_count = 2 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_reset_password.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | alias = "%s" 8 | name = "%s" 9 | region = "%s" 10 | version = data.ec_stack.latest.version 11 | deployment_template_id = "%s" 12 | 13 | elasticsearch = { 14 | hot = { 15 | size = "1g" 16 | autoscaling = {} 17 | } 18 | } 19 | 20 | kibana = { 21 | instance_configuration_id = "%s" 22 | } 23 | 24 | apm = { 25 | instance_configuration_id = "%s" 26 | } 27 | 28 | enterprise_search = { 29 | instance_configuration_id = "%s" 30 | } 31 | 32 | reset_elasticsearch_password = true 33 | } 34 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_settings_config_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = { 20 | instance_configuration_id = "%s" 21 | } 22 | 23 | apm = { 24 | instance_configuration_id = "%s" 25 | } 26 | 27 | enterprise_search = { 28 | instance_configuration_id = "%s" 29 | } 30 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_settings_config_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | config = { 14 | user_settings_yaml = "action.auto_create_index: true" 15 | } 16 | hot = { 17 | size = "1g" 18 | autoscaling = {} 19 | } 20 | } 21 | 22 | kibana = { 23 | config = { 24 | user_settings_yaml = "csp.warnLegacyBrowsers: true" 25 | } 26 | 27 | instance_configuration_id = "%s" 28 | } 29 | 30 | apm = { 31 | config = { 32 | debug_enabled = true 33 | user_settings_json = jsonencode({ "apm-server.rum.enabled" = true }) 34 | } 35 | 36 | instance_configuration_id = "%s" 37 | } 38 | 39 | enterprise_search = { 40 | config = { 41 | user_settings_yaml = "# comment" 42 | } 43 | 44 | instance_configuration_id = "%s" 45 | } 46 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_settings_config_import.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | 18 | warm = { 19 | autoscaling = {} 20 | } 21 | 22 | cold = { 23 | autoscaling = {} 24 | } 25 | 26 | frozen = { 27 | autoscaling = {} 28 | } 29 | 30 | ml = { 31 | autoscaling = {} 32 | } 33 | 34 | master = { 35 | autoscaling = {} 36 | } 37 | 38 | coordinating = { 39 | autoscaling = {} 40 | } 41 | 42 | config = {} 43 | } 44 | 45 | kibana = { 46 | instance_configuration_id = "%s" 47 | } 48 | 49 | apm = { 50 | instance_configuration_id = "%s" 51 | } 52 | 53 | enterprise_search = { 54 | instance_configuration_id = "%s" 55 | } 56 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_tags_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tags" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | tags = { 20 | owner = "elastic" 21 | cost-center = "rnd" 22 | } 23 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_tags_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tags" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | tags = { 20 | owner = "elastic" 21 | } 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_tags_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tags" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_tags_4.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tags" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | tags = { 20 | new = "tag" 21 | } 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_with_traffic_filter_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | apm = {} 22 | 23 | enterprise_search = {} 24 | 25 | traffic_filter = [ 26 | ec_deployment_traffic_filter.default.id, 27 | ] 28 | } 29 | 30 | resource "ec_deployment_traffic_filter" "default" { 31 | name = "%s" 32 | region = "%s" 33 | type = "ip" 34 | 35 | rule { 36 | source = "0.0.0.0/0" 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_basic_with_traffic_filter_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | apm = {} 22 | 23 | enterprise_search = {} 24 | 25 | traffic_filter = [ 26 | ec_deployment_traffic_filter.second.id, 27 | ] 28 | } 29 | 30 | resource "ec_deployment_traffic_filter" "second" { 31 | name = "%s" 32 | region = "%s" 33 | type = "ip" 34 | 35 | rule { 36 | source = "0.0.0.0/0" 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_ccs_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "general_purpose" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | 17 | "remote_cluster" = [for source_storage_optimized in ec_deployment.source_storage_optimized : 18 | { 19 | deployment_id = source_storage_optimized.id 20 | alias = source_storage_optimized.name 21 | } 22 | ] 23 | } 24 | } 25 | 26 | resource "ec_deployment" "source_storage_optimized" { 27 | count = 3 28 | name = "%s-${count.index}" 29 | region = "%s" 30 | version = data.ec_stack.latest.version 31 | deployment_template_id = "%s" 32 | 33 | elasticsearch = { 34 | hot = { 35 | zone_count = 1 36 | size = "1g" 37 | autoscaling = {} 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_ccs_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "general_purpose" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "4g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | # kibana = {} 20 | } 21 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_cpu_optimized_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "cpu_optimized" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | } 20 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_cpu_optimized_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "cpu_optimized" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | apm = { 22 | size = "2g" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_cpu_optimized_with_custom_hot_ic.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "cpu_optimized" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | instance_configuration_id = "aws.es.datahot.m5d" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | } 21 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_cpu_optimized_with_migrate_to_latest_hw.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "cpu_optimized" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | migrate_to_latest_hardware = true 12 | 13 | elasticsearch = { 14 | hot = { 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | } 21 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_dedicated_coordinating.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "dedicated_coordinating" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | coordinating = { 14 | zone_count = 2 15 | size = "1g" 16 | autoscaling = {} 17 | } 18 | 19 | hot = { 20 | zone_count = 1 21 | size = "1g" 22 | autoscaling = {} 23 | } 24 | 25 | warm = { 26 | zone_count = 1 27 | size = "2g" 28 | autoscaling = {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_dedicated_master_5_nodes.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "auto_dedicated_master" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | zone_count = 2 16 | autoscaling = {} 17 | } 18 | 19 | warm = { 20 | size = "2g" 21 | zone_count = 3 22 | autoscaling = {} 23 | } 24 | } 25 | 26 | kibana = {} 27 | } 28 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_dedicated_master_6_nodes.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "auto_dedicated_master" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | zone_count = 3 16 | autoscaling = {} 17 | } 18 | 19 | warm = { 20 | size = "2g" 21 | zone_count = 3 22 | autoscaling = {} 23 | } 24 | } 25 | 26 | kibana = {} 27 | } 28 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_dedicated_master_above_threshold.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "dedicated_master" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | cold = { 14 | zone_count = 1 15 | size = "2g" 16 | autoscaling = {} 17 | } 18 | 19 | hot = { 20 | zone_count = 3 21 | size = "1g" 22 | autoscaling = {} 23 | } 24 | 25 | master = { 26 | zone_count = 3 27 | size = "1g" 28 | autoscaling = {} 29 | } 30 | 31 | warm = { 32 | zone_count = 2 33 | size = "2g" 34 | autoscaling = {} 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_dedicated_master_below_threshold.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "dedicated_master" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | zone_count = 3 15 | size = "1g" 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_docker_image_override.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | name = "%s" 3 | region = "%s" 4 | deployment_template = "%s" 5 | } 6 | 7 | data "ec_stack" "latest" { 8 | version_regex = "7.15.?" 9 | region = local.region 10 | } 11 | 12 | resource "ec_deployment" "docker_image" { 13 | name = local.name 14 | region = local.region 15 | version = data.ec_stack.latest.version 16 | deployment_template_id = local.deployment_template 17 | 18 | elasticsearch = { 19 | config = { 20 | docker_image = "docker.elastic.co/cloud-ci/elasticsearch:7.15.0-SNAPSHOT" 21 | } 22 | 23 | hot = { 24 | size = "1g" 25 | zone_count = 1 26 | autoscaling = {} 27 | } 28 | } 29 | 30 | kibana = { 31 | config = { 32 | docker_image = "docker.elastic.co/cloud-ci/kibana:7.15.0-SNAPSHOT" 33 | } 34 | } 35 | 36 | apm = { 37 | config = { 38 | docker_image = "docker.elastic.co/cloud-ci/apm:7.15.0-SNAPSHOT" 39 | } 40 | } 41 | 42 | enterprise_search = { 43 | config = { 44 | docker_image = "docker.elastic.co/cloud-ci/enterprise-search:7.15.0-SNAPSHOT" 45 | } 46 | 47 | zone_count = 1 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "keystore" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "keystore" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.keystore.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment_elasticsearch_keystore" "test" { 22 | deployment_id = ec_deployment.keystore.id 23 | setting_name = "xpack.notification.slack.account.hello.secure_url" 24 | value = "hella" 25 | } 26 | 27 | resource "ec_deployment_elasticsearch_keystore" "gcs_creds" { 28 | deployment_id = ec_deployment.keystore.id 29 | setting_name = "gcs.client.secondary.credentials_file" 30 | value = file("testdata/deployment_elasticsearch_keystore_creds.json") 31 | } 32 | 33 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_1_041.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "keystore" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "keystore" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.keystore.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch { 13 | topology { 14 | id = "hot_content" 15 | size = "1g" 16 | zone_count = 1 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment_elasticsearch_keystore" "test" { 22 | deployment_id = ec_deployment.keystore.id 23 | setting_name = "xpack.notification.slack.account.hello.secure_url" 24 | value = "hella" 25 | } 26 | 27 | resource "ec_deployment_elasticsearch_keystore" "gcs_creds" { 28 | deployment_id = ec_deployment.keystore.id 29 | setting_name = "gcs.client.secondary.credentials_file" 30 | value = file("testdata/deployment_elasticsearch_keystore_creds.json") 31 | } 32 | 33 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_1_migrated.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "keystore" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "keystore" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.keystore.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment_elasticsearch_keystore" "test" { 22 | deployment_id = ec_deployment.keystore.id 23 | setting_name = "xpack.notification.slack.account.hello.secure_url" 24 | value = "hella" 25 | } 26 | 27 | resource "ec_deployment_elasticsearch_keystore" "gcs_creds" { 28 | deployment_id = ec_deployment.keystore.id 29 | setting_name = "gcs.client.secondary.credentials_file" 30 | value = file("testdata/deployment_elasticsearch_keystore_creds.json") 31 | } 32 | 33 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "keystore" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "keystore" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.keystore.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment_elasticsearch_keystore" "test" { 22 | deployment_id = ec_deployment.keystore.id 23 | setting_name = "xpack.notification.slack.account.hello.secure_url" 24 | value = "hello2u" 25 | } 26 | 27 | resource "ec_deployment_elasticsearch_keystore" "gcs_creds" { 28 | deployment_id = ec_deployment.keystore.id 29 | setting_name = "gcs.client.secondary.credentials_file" 30 | value = file("testdata/deployment_elasticsearch_keystore_creds.json") 31 | } 32 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "keystore" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "keystore" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.keystore.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment_elasticsearch_keystore" "test" { 22 | deployment_id = ec_deployment.keystore.id 23 | setting_name = "xpack.notification.slack.account.hello.secure_urla" 24 | value = "hello2u" 25 | } 26 | 27 | resource "ec_deployment_elasticsearch_keystore" "gcs_creds" { 28 | deployment_id = ec_deployment.keystore.id 29 | setting_name = "gcs.client.secondary.credentials_file" 30 | value = file("testdata/deployment_elasticsearch_keystore_creds.json") 31 | } 32 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_4.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "keystore" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "keystore" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.keystore.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_elasticsearch_keystore_creds.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "service_account", 3 | "project_id": "project-id", 4 | "private_key_id": "key-id", 5 | "private_key": "-----BEGIN PRIVATE KEY-----\nprivate-key\n-----END PRIVATE KEY-----\n", 6 | "client_email": "service-account-email", 7 | "client_id": "client-id", 8 | "auth_uri": "https://accounts.google.com/o/oauth2/auth", 9 | "token_uri": "https://accounts.google.com/o/oauth2/token", 10 | "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 11 | "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account-email" 12 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_emptyconfig.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "emptyconfig" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "emptyconfig" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.emptyconfig.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | config = { 14 | user_settings_yaml = null 15 | } 16 | hot = { 17 | size = "1g" 18 | zone_count = 1 19 | autoscaling = {} 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_enterprise_search_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "enterprise_search" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | 20 | enterprise_search = {} 21 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_enterprise_search_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "enterprise_search" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | enterprise_search = {} 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_general_purpose_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "general_purpose" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | 17 | warm = { 18 | autoscaling = {} 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_general_purpose_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "general_purpose" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | zone_count = 1 15 | size = "1g" 16 | autoscaling = {} 17 | } 18 | 19 | warm = { 20 | zone_count = 1 21 | size = "2g" 22 | autoscaling = {} 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_keystore_update2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "test" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | 18 | ml = { 19 | autoscaling = {} 20 | } 21 | } 22 | 23 | kibana = { 24 | zone_count = 1 25 | } 26 | 27 | } 28 | 29 | resource "ec_deployment_elasticsearch_keystore" "test" { 30 | deployment_id = ec_deployment.test.id 31 | setting_name = "xpack.notification.slack.account.monitoring.secure_url" 32 | value = "secret-2" 33 | } 34 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_memory_optimized_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "memory_optimized" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_memory_optimized_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "memory_optimized" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | apm = {} 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment" "observability" { 22 | name = "%s" 23 | region = "%s" 24 | version = data.ec_stack.latest.version 25 | deployment_template_id = "%s" 26 | 27 | elasticsearch = { 28 | hot = { 29 | size = "1g" 30 | zone_count = 1 31 | autoscaling = {} 32 | } 33 | } 34 | 35 | observability = { 36 | deployment_id = ec_deployment.basic.id 37 | } 38 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment" "observability" { 22 | name = "%s" 23 | region = "%s" 24 | version = data.ec_stack.latest.version 25 | deployment_template_id = "%s" 26 | 27 | elasticsearch = { 28 | hot = { 29 | size = "1g" 30 | zone_count = 1 31 | autoscaling = {} 32 | } 33 | } 34 | 35 | observability = { 36 | deployment_id = ec_deployment.basic.id 37 | metrics = false 38 | } 39 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment" "observability" { 22 | name = "%s" 23 | region = "%s" 24 | version = data.ec_stack.latest.version 25 | deployment_template_id = "%s" 26 | 27 | elasticsearch = { 28 | hot = { 29 | size = "1g" 30 | zone_count = 1 31 | autoscaling = {} 32 | } 33 | } 34 | 35 | observability = { 36 | deployment_id = ec_deployment.basic.id 37 | logs = false 38 | } 39 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_4.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "basic" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment" "observability" { 22 | name = "%s" 23 | region = "%s" 24 | version = data.ec_stack.latest.version 25 | deployment_template_id = "%s" 26 | 27 | elasticsearch = { 28 | hot = { 29 | size = "1g" 30 | zone_count = 1 31 | autoscaling = {} 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_self.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "observability" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | observability = { 13 | deployment_id = "self" 14 | } 15 | 16 | elasticsearch = { 17 | autoscale = "false" 18 | 19 | hot = { 20 | size = "1g" 21 | zone_count = 1 22 | autoscaling = {} 23 | } 24 | } 25 | 26 | kibana = { 27 | size = "1g" 28 | zone_count = 1 29 | } 30 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_tpl_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "observability_tpl" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | 20 | apm = {} 21 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_observability_tpl_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "observability_tpl" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | apm = {} 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_post_node_roles_upgrade_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "post_node_roles_upgrade" { 2 | version_regex = "7.12.?" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "post_nr_upgrade" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.post_node_roles_upgrade.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | 20 | kibana = {} 21 | enterprise_search = {} 22 | } 23 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_post_node_roles_upgrade_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "post_node_roles_upgrade" { 2 | version_regex = "7.12.?" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "post_nr_upgrade" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.post_node_roles_upgrade.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_post_node_roles_upgrade_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "post_node_roles_upgrade" { 2 | version_regex = "7.17.?" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "post_nr_upgrade" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.post_node_roles_upgrade.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_pre_node_roles_migration_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "pre_node_roles" { 2 | version_regex = "^7\\.9\\.\\d{1,2}$" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "pre_nr" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.pre_node_roles.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_pre_node_roles_migration_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "pre_node_roles" { 2 | version_regex = "^7\\.\\d{1,2}\\.\\d{1,2}$" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "pre_nr" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.pre_node_roles.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_pre_node_roles_migration_3.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "pre_node_roles" { 2 | version_regex = "^7\\.\\d{1,2}\\.\\d{1,2}$" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "pre_nr" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.pre_node_roles.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | zone_count = 1 16 | autoscaling = {} 17 | } 18 | 19 | warm = { 20 | size = "2g" 21 | zone_count = 1 22 | autoscaling = {} 23 | } 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_security_1.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "security" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | autoscaling = {} 15 | } 16 | } 17 | 18 | kibana = {} 19 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_security_2.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "security" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "2g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | apm = {} 22 | } -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_snapshot_1.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | region = "%s" 3 | deployment_template = "%s" 4 | } 5 | 6 | data "ec_stack" "latest" { 7 | version_regex = "latest" 8 | region = local.region 9 | } 10 | 11 | resource "ec_deployment" "snapshot_source" { 12 | name = "terraform_acc_snapshot_source" 13 | region = local.region 14 | version = data.ec_stack.latest.version 15 | deployment_template_id = local.deployment_template 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | autoscaling = {} 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_snapshot_2.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | region = "%s" 3 | deployment_template = "%s" 4 | } 5 | 6 | data "ec_stack" "latest" { 7 | version_regex = "latest" 8 | region = local.region 9 | } 10 | 11 | resource "ec_deployment" "snapshot_source" { 12 | name = "terraform_acc_snapshot_source" 13 | region = local.region 14 | version = data.ec_stack.latest.version 15 | deployment_template_id = local.deployment_template 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | autoscaling = {} 21 | } 22 | } 23 | } 24 | 25 | resource "ec_deployment" "snapshot_target" { 26 | name = "terraform_acc_snapshot_target" 27 | region = local.region 28 | version = data.ec_stack.latest.version 29 | deployment_template_id = local.deployment_template 30 | 31 | elasticsearch = { 32 | 33 | snapshot_source = [{ 34 | source_elasticsearch_cluster_id = ec_deployment.snapshot_source.elasticsearch.0.resource_id 35 | }] 36 | 37 | hot = { 38 | size = "1g" 39 | autoscaling = {} 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_association_basic.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tf_assoc" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | } 21 | 22 | resource "ec_deployment_traffic_filter" "tf_assoc" { 23 | name = "%s" 24 | region = "%s" 25 | type = "ip" 26 | 27 | rule { 28 | source = "0.0.0.0/0" 29 | } 30 | } 31 | 32 | resource "ec_deployment_traffic_filter_association" "tf_assoc" { 33 | traffic_filter_id = ec_deployment_traffic_filter.tf_assoc.id 34 | deployment_id = ec_deployment.tf_assoc.id 35 | } 36 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_association_basic_041.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tf_assoc" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch { 13 | topology { 14 | id = "hot_content" 15 | size = "1g" 16 | } 17 | } 18 | 19 | kibana {} 20 | } 21 | 22 | resource "ec_deployment_traffic_filter" "tf_assoc" { 23 | name = "%s" 24 | region = "%s" 25 | type = "ip" 26 | 27 | rule { 28 | source = "0.0.0.0/0" 29 | } 30 | } 31 | 32 | resource "ec_deployment_traffic_filter_association" "tf_assoc" { 33 | traffic_filter_id = ec_deployment_traffic_filter.tf_assoc.id 34 | deployment_id = ec_deployment.tf_assoc.id 35 | } 36 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_association_basic_ignore_changes.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tf_assoc" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | 21 | lifecycle { 22 | ignore_changes = [traffic_filter] 23 | } 24 | } 25 | 26 | resource "ec_deployment_traffic_filter" "tf_assoc" { 27 | name = "%s" 28 | region = "%s" 29 | type = "ip" 30 | 31 | rule { 32 | source = "0.0.0.0/0" 33 | } 34 | } 35 | 36 | resource "ec_deployment_traffic_filter_association" "tf_assoc" { 37 | traffic_filter_id = ec_deployment_traffic_filter.tf_assoc.id 38 | deployment_id = ec_deployment.tf_assoc.id 39 | } 40 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_association_basic_update.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "%s" 4 | } 5 | 6 | resource "ec_deployment" "tf_assoc" { 7 | name = "%s" 8 | region = "%s" 9 | version = data.ec_stack.latest.version 10 | deployment_template_id = "%s" 11 | 12 | elasticsearch = { 13 | hot = { 14 | size = "1g" 15 | autoscaling = {} 16 | } 17 | } 18 | 19 | kibana = {} 20 | } 21 | 22 | resource "ec_deployment_traffic_filter" "tf_assoc_second" { 23 | name = "%s" 24 | region = "%s" 25 | type = "ip" 26 | 27 | rule { 28 | source = "0.0.0.0/0" 29 | } 30 | } 31 | 32 | resource "ec_deployment_traffic_filter_association" "tf_assoc" { 33 | traffic_filter_id = ec_deployment_traffic_filter.tf_assoc_second.id 34 | deployment_id = ec_deployment.tf_assoc.id 35 | } 36 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_azure.tf: -------------------------------------------------------------------------------- 1 | resource "ec_deployment_traffic_filter" "azure" { 2 | name = "%s" 3 | region = "%s" 4 | type = "azure_private_endpoint" 5 | 6 | rule { 7 | azure_endpoint_name = "my-azure-pl" 8 | azure_endpoint_guid = "78c64959-fd88-41cc-81ac-1cfcdb1ac32e" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_basic.tf: -------------------------------------------------------------------------------- 1 | resource "ec_deployment_traffic_filter" "basic" { 2 | name = "%s" 3 | region = "%s" 4 | type = "ip" 5 | 6 | rule { 7 | source = "0.0.0.0/0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_basic_update.tf: -------------------------------------------------------------------------------- 1 | resource "ec_deployment_traffic_filter" "basic" { 2 | name = "%s" 3 | region = "%s" 4 | type = "ip" 5 | 6 | rule { 7 | source = "0.0.0.0/0" 8 | } 9 | 10 | rule { 11 | source = "1.1.1.0/24" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_traffic_filter_basic_update_large.tf: -------------------------------------------------------------------------------- 1 | variable "google_dns_rules" { 2 | type = list(string) 3 | default = [ 4 | "8.8.8.8/24", "8.8.4.4/24", "8.8.8.9/24", "8.8.4.10/24", "8.8.8.11/24", "8.8.4.12/24", "8.8.8.13/24", "8.8.4.14/24", 5 | "9.8.8.8/24", "10.8.4.4/24", "11.8.8.9/24", "12.8.4.10/24", "13.8.8.11/24", "14.8.4.12/24", "15.8.8.13/24", "16.8.4.14/24", 6 | ] 7 | } 8 | 9 | resource "ec_deployment_traffic_filter" "basic" { 10 | name = "%s" 11 | region = "%s" 12 | type = "ip" 13 | 14 | dynamic "rule" { 15 | for_each = var.google_dns_rules 16 | content { 17 | source = rule.value 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_upgrade_retry_1.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | region = "%s" 3 | deployment_template = "%s" 4 | } 5 | 6 | data "ec_stack" "latest" { 7 | version_regex = "7\\.10\\.\\d+?" 8 | region = local.region 9 | } 10 | 11 | resource "ec_deployment" "upgrade_retry" { 12 | name = "terraform_acc_upgrade_retry" 13 | region = local.region 14 | version = data.ec_stack.latest.version 15 | deployment_template_id = local.deployment_template 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | zone_count = 1 21 | autoscaling = {} 22 | } 23 | } 24 | 25 | kibana = {} 26 | } 27 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_upgrade_retry_2.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | region = "%s" 3 | deployment_template = "%s" 4 | } 5 | 6 | data "ec_stack" "latest" { 7 | version_regex = "7\\.11\\.\\d+?" 8 | region = local.region 9 | } 10 | 11 | resource "ec_deployment" "upgrade_retry" { 12 | name = "terraform_acc_upgrade_retry" 13 | region = local.region 14 | version = data.ec_stack.latest.version 15 | deployment_template_id = local.deployment_template 16 | 17 | elasticsearch = { 18 | hot = { 19 | size = "1g" 20 | zone_count = 1 21 | autoscaling = {} 22 | } 23 | } 24 | 25 | kibana = {} 26 | } 27 | -------------------------------------------------------------------------------- /ec/acc/testdata/deployment_with_extension_bundle_file.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | region = "%s" 3 | deployment_template = "%s" 4 | name = "%s" 5 | description = "%s" 6 | file_path = "%s" 7 | } 8 | 9 | data "ec_stack" "latest" { 10 | version_regex = "latest" 11 | region = local.region 12 | } 13 | 14 | resource "ec_deployment" "with_extension" { 15 | name = local.name 16 | region = local.region 17 | version = data.ec_stack.latest.version 18 | deployment_template_id = local.deployment_template 19 | 20 | elasticsearch = { 21 | hot = { 22 | autoscaling = {} 23 | } 24 | extension = [{ 25 | type = "bundle" 26 | name = local.name 27 | version = data.ec_stack.latest.version 28 | url = ec_deployment_extension.my_extension.url 29 | }] 30 | } 31 | } 32 | 33 | resource "ec_deployment_extension" "my_extension" { 34 | name = local.name 35 | description = local.description 36 | version = "*" 37 | extension_type = "bundle" 38 | 39 | file_path = local.file_path 40 | file_hash = filebase64sha256(local.file_path) 41 | } 42 | -------------------------------------------------------------------------------- /ec/acc/testdata/extension_basic.tf: -------------------------------------------------------------------------------- 1 | resource "ec_deployment_extension" "my_extension" { 2 | name = "%s" 3 | description = "%s" 4 | version = "*" 5 | extension_type = "bundle" 6 | } 7 | -------------------------------------------------------------------------------- /ec/acc/testdata/extension_bundle_file.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | file_path = "%s" 3 | } 4 | 5 | resource "ec_deployment_extension" "my_extension" { 6 | name = "%s" 7 | description = "%s" 8 | version = "*" 9 | extension_type = "bundle" 10 | 11 | file_path = local.file_path 12 | file_hash = filebase64sha256(local.file_path) 13 | } 14 | -------------------------------------------------------------------------------- /ec/acc/testdata/extension_plugin_download.tf: -------------------------------------------------------------------------------- 1 | resource "ec_deployment_extension" "my_extension" { 2 | name = "%s" 3 | version = "7.10.1" 4 | extension_type = "plugin" 5 | download_url = "%s" 6 | } 7 | -------------------------------------------------------------------------------- /ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package deploymentdatasource 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/diag" 24 | "github.com/hashicorp/terraform-plugin-framework/types" 25 | 26 | "github.com/elastic/cloud-sdk-go/pkg/models" 27 | ) 28 | 29 | // flattenTrafficFiltering parses a deployment's traffic filtering settings. 30 | func flattenTrafficFiltering(ctx context.Context, settings *models.DeploymentSettings) (types.List, diag.Diagnostics) { 31 | target := types.ListNull(types.StringType) 32 | 33 | if settings == nil || settings.TrafficFilterSettings == nil { 34 | return target, nil 35 | } 36 | 37 | return types.ListValueFrom(ctx, target.ElementType(ctx), settings.TrafficFilterSettings.Rulesets) 38 | } 39 | -------------------------------------------------------------------------------- /ec/ecdatasource/deploymenttemplates/model_stateless.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package deploymenttemplates 19 | 20 | type statelessModel struct { 21 | InstanceConfigurationId string `tfsdk:"instance_configuration_id"` 22 | InstanceConfigurationVersion *int32 `tfsdk:"instance_configuration_version"` 23 | DefaultSize *string `tfsdk:"default_size"` 24 | AvailableSizes []string `tfsdk:"available_sizes"` 25 | SizeResource *string `tfsdk:"size_resource"` 26 | } 27 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v1/elasticsearch_extension.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ElasticsearchExtensionTF struct { 25 | Name types.String `tfsdk:"name"` 26 | Type types.String `tfsdk:"type"` 27 | Version types.String `tfsdk:"version"` 28 | Url types.String `tfsdk:"url"` 29 | } 30 | 31 | type ElasticsearchExtensionsTF types.Set 32 | 33 | type ElasticsearchExtension struct { 34 | Name string `tfsdk:"name"` 35 | Type string `tfsdk:"type"` 36 | Version string `tfsdk:"version"` 37 | Url string `tfsdk:"url"` 38 | } 39 | 40 | type ElasticsearchExtensions []ElasticsearchExtension 41 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v1/elasticsearch_remote_cluster.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ElasticsearchRemoteClusterTF struct { 25 | DeploymentId types.String `tfsdk:"deployment_id"` 26 | Alias types.String `tfsdk:"alias"` 27 | RefId types.String `tfsdk:"ref_id"` 28 | SkipUnavailable types.Bool `tfsdk:"skip_unavailable"` 29 | } 30 | 31 | type ElasticsearchRemoteCluster struct { 32 | DeploymentId *string `tfsdk:"deployment_id"` 33 | Alias *string `tfsdk:"alias"` 34 | RefId *string `tfsdk:"ref_id"` 35 | SkipUnavailable *bool `tfsdk:"skip_unavailable"` 36 | } 37 | 38 | type ElasticsearchRemoteClusters []ElasticsearchRemoteCluster 39 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v1/elasticsearch_snapshot_source.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ElasticsearchSnapshotSourceTF struct { 25 | SourceElasticsearchClusterId types.String `tfsdk:"source_elasticsearch_cluster_id"` 26 | SnapshotName types.String `tfsdk:"snapshot_name"` 27 | } 28 | 29 | type ElasticsearchSnapshotSource struct { 30 | SourceElasticsearchClusterId string `tfsdk:"source_elasticsearch_cluster_id"` 31 | SnapshotName string `tfsdk:"snapshot_name"` 32 | } 33 | 34 | type ElasticsearchSnapshotSources []ElasticsearchSnapshotSource 35 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v1/elasticsearch_strategy.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ElasticsearchStrategyTF struct { 25 | Type types.String `tfsdk:"type"` 26 | } 27 | 28 | type ElasticsearchStrategiesTF types.List 29 | 30 | type ElasticsearchStrategy struct { 31 | Type string `tfsdk:"type"` 32 | } 33 | 34 | type ElasticsearchStrategies []ElasticsearchStrategy 35 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v1/elasticsearch_trust_account.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ElasticsearchTrustAccountTF struct { 25 | AccountId types.String `tfsdk:"account_id"` 26 | TrustAll types.Bool `tfsdk:"trust_all"` 27 | TrustAllowlist types.Set `tfsdk:"trust_allowlist"` 28 | } 29 | 30 | type ElasticsearchTrustAccountsTF types.Set 31 | 32 | type ElasticsearchTrustAccount struct { 33 | AccountId *string `tfsdk:"account_id"` 34 | TrustAll *bool `tfsdk:"trust_all"` 35 | TrustAllowlist []string `tfsdk:"trust_allowlist"` 36 | } 37 | 38 | type ElasticsearchTrustAccounts []ElasticsearchTrustAccount 39 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v1/elasticsearch_trust_external.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ElasticsearchTrustExternalTF struct { 25 | RelationshipId types.String `tfsdk:"relationship_id"` 26 | TrustAll types.Bool `tfsdk:"trust_all"` 27 | TrustAllowlist types.Set `tfsdk:"trust_allowlist"` 28 | } 29 | 30 | type ElasticsearchTrustExternal struct { 31 | RelationshipId *string `tfsdk:"relationship_id"` 32 | TrustAll *bool `tfsdk:"trust_all"` 33 | TrustAllowlist []string `tfsdk:"trust_allowlist"` 34 | } 35 | 36 | type ElasticsearchTrustExternals []ElasticsearchTrustExternal 37 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_test_utils.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v2 19 | 20 | import "github.com/elastic/cloud-sdk-go/pkg/models" 21 | 22 | func CreateTierForTest(tierId string, tier ElasticsearchTopology) *ElasticsearchTopology { 23 | res := tier 24 | res.id = tierId 25 | return &res 26 | } 27 | 28 | func EnrichWithEmptyTopologies(tpl, want *models.ElasticsearchPayload) *models.ElasticsearchPayload { 29 | tpl.DisplayName = want.DisplayName 30 | tpl.RefID = want.RefID 31 | tpl.Region = want.Region 32 | tpl.Settings = want.Settings 33 | tpl.Plan.AutoscalingEnabled = want.Plan.AutoscalingEnabled 34 | tpl.Plan.Elasticsearch = want.Plan.Elasticsearch 35 | tpl.Plan.Transient = want.Plan.Transient 36 | 37 | for i, t := range tpl.Plan.ClusterTopology { 38 | for _, w := range want.Plan.ClusterTopology { 39 | if t.ID == w.ID { 40 | tpl.Plan.ClusterTopology[i] = w 41 | } 42 | } 43 | } 44 | 45 | return tpl 46 | } 47 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/observability/v1/observability.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type ObservabilityTF struct { 25 | DeploymentId types.String `tfsdk:"deployment_id"` 26 | RefId types.String `tfsdk:"ref_id"` 27 | Logs types.Bool `tfsdk:"logs"` 28 | Metrics types.Bool `tfsdk:"metrics"` 29 | } 30 | 31 | type Observability struct { 32 | DeploymentId *string `tfsdk:"deployment_id"` 33 | RefId *string `tfsdk:"ref_id"` 34 | Logs bool `tfsdk:"logs"` 35 | Metrics bool `tfsdk:"metrics"` 36 | } 37 | 38 | type Observabilities []Observability 39 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/observability/v1/schema.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/resource/schema" 22 | ) 23 | 24 | func ObservabilitySchema() schema.Attribute { 25 | return schema.ListNestedAttribute{ 26 | Description: "Optional observability settings. Ship logs and metrics to a dedicated deployment.", 27 | Optional: true, 28 | NestedObject: schema.NestedAttributeObject{ 29 | Attributes: map[string]schema.Attribute{ 30 | "deployment_id": schema.StringAttribute{ 31 | Required: true, 32 | }, 33 | "ref_id": schema.StringAttribute{ 34 | Computed: true, 35 | Optional: true, 36 | }, 37 | "logs": schema.BoolAttribute{ 38 | Optional: true, 39 | Computed: true, 40 | }, 41 | "metrics": schema.BoolAttribute{ 42 | Optional: true, 43 | Computed: true, 44 | }, 45 | }, 46 | }, 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/testdata/template-empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "deployment_template": { 3 | "resources": { 4 | "apm": null, 5 | "appsearch": null, 6 | "elasticsearch": null, 7 | "enterprise_search": null, 8 | "kibana": null 9 | } 10 | }, 11 | "description": "Search data across one or more associated remote deployments.", 12 | "id": "empty-deployment-template", 13 | "instance_configurations": [ 14 | { 15 | "description": "A Kibana instance running on an AWS r5d.", 16 | "discrete_sizes": { 17 | "default_size": 1024, 18 | "resource": "memory", 19 | "sizes": [ 20 | 1024, 21 | 2048, 22 | 4096, 23 | 8192 24 | ] 25 | }, 26 | "id": "aws.kibana.r5d", 27 | "instance_type": "kibana", 28 | "name": "aws.kibana.r5d", 29 | "node_types": null, 30 | "storage_multiplier": 2 31 | } 32 | ], 33 | "metadata": [ 34 | { 35 | "key": "parent_solution", 36 | "value": "stack" 37 | } 38 | ], 39 | "min_version": "6.7.0", 40 | "name": "Kibana only", 41 | "order": 5, 42 | "system_owned": true 43 | } -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/topology/v1/topology.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package v1 19 | 20 | import ( 21 | "github.com/hashicorp/terraform-plugin-framework/types" 22 | ) 23 | 24 | type TopologyTF struct { 25 | InstanceConfigurationId types.String `tfsdk:"instance_configuration_id"` 26 | InstanceConfigurationVersion types.Int64 `tfsdk:"instance_configuration_version"` 27 | Size types.String `tfsdk:"size"` 28 | SizeResource types.String `tfsdk:"size_resource"` 29 | ZoneCount types.Int64 `tfsdk:"zone_count"` 30 | } 31 | 32 | type Topology struct { 33 | InstanceConfigurationId *string `tfsdk:"instance_configuration_id"` 34 | InstanceConfigurationVersion *int `tfsdk:"instance_configuration_version"` 35 | Size *string `tfsdk:"size"` 36 | SizeResource *string `tfsdk:"size_resource"` 37 | ZoneCount int `tfsdk:"zone_count"` 38 | } 39 | 40 | type Topologies []Topology 41 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/utils/definitions.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package utils 19 | 20 | import "github.com/blang/semver" 21 | 22 | const ( 23 | MinimumZoneCount = 1 24 | ) 25 | 26 | var ( 27 | DataTiersVersion = semver.MustParse("7.10.0") 28 | MinVersionWithoutNodeTypes = semver.MustParse("8.0.0") 29 | ) 30 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/utils/missing_field_error.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package utils 19 | 20 | import "fmt" 21 | 22 | func MissingField(field string) error { 23 | return fmt.Errorf("server response doesn't contain deployment '%s'", field) 24 | } 25 | -------------------------------------------------------------------------------- /ec/ecresource/deploymentresource/wait.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package deploymentresource 19 | 20 | import ( 21 | "time" 22 | 23 | "github.com/elastic/cloud-sdk-go/pkg/api" 24 | "github.com/elastic/cloud-sdk-go/pkg/plan" 25 | "github.com/elastic/cloud-sdk-go/pkg/plan/planutil" 26 | ) 27 | 28 | const ( 29 | defaultPollPlanFrequency = 2 * time.Second 30 | defaultMaxPlanRetry = 4 31 | ) 32 | 33 | // WaitForPlanCompletion waits for a pending plan to finish. 34 | func WaitForPlanCompletion(client *api.API, id string) error { 35 | return planutil.Wait(plan.TrackChangeParams{ 36 | API: client, DeploymentID: id, 37 | Config: plan.TrackFrequencyConfig{ 38 | PollFrequency: defaultPollPlanFrequency, 39 | MaxRetries: defaultMaxPlanRetry, 40 | }, 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /ec/ecresource/elasticsearchkeystoreresource/expanders.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package elasticsearchkeystoreresource 19 | 20 | import ( 21 | "context" 22 | "encoding/json" 23 | 24 | "github.com/elastic/cloud-sdk-go/pkg/models" 25 | "github.com/elastic/cloud-sdk-go/pkg/util/ec" 26 | ) 27 | 28 | func expandModel(ctx context.Context, state modelV0) *models.KeystoreContents { 29 | var value interface{} 30 | secretName := state.SettingName.ValueString() 31 | strVal := state.Value.ValueString() 32 | 33 | // Tries to unmarshal the contents of the value into an `interface{}`, 34 | // if it fails, then the contents aren't a JSON object. 35 | if err := json.Unmarshal([]byte(strVal), &value); err != nil { 36 | value = strVal 37 | } 38 | 39 | return &models.KeystoreContents{ 40 | Secrets: map[string]models.KeystoreSecret{ 41 | secretName: { 42 | AsFile: ec.Bool(state.AsFile.ValueBool()), 43 | Value: value, 44 | }, 45 | }, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ec/ecresource/extensionresource/testdata/test_extension_bundle.json: -------------------------------------------------------------------------------- 1 | {"foo": "bar"} -------------------------------------------------------------------------------- /ec/ecresource/extensionresource/upload.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package extensionresource 19 | 20 | import ( 21 | "os" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/diag" 24 | 25 | "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/extensionapi" 26 | ) 27 | 28 | func (r *Resource) uploadExtension(state modelV0) diag.Diagnostics { 29 | var diags diag.Diagnostics 30 | 31 | reader, err := os.Open(state.FilePath.ValueString()) 32 | if err != nil { 33 | diags.AddError("failed to open file", err.Error()) 34 | return diags 35 | } 36 | 37 | _, err = extensionapi.Upload(extensionapi.UploadParams{ 38 | API: r.client, 39 | ExtensionID: state.ID.ValueString(), 40 | File: reader, 41 | }) 42 | if err != nil { 43 | diags.AddError("failed to upload file", err.Error()) 44 | return diags 45 | } 46 | 47 | return diags 48 | } 49 | -------------------------------------------------------------------------------- /ec/ecresource/organizationresource/import.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package organizationresource 19 | 20 | import ( 21 | "context" 22 | "github.com/hashicorp/terraform-plugin-framework/resource" 23 | ) 24 | 25 | func (r *Resource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { 26 | organizationID := request.ID 27 | 28 | result := r.readFromApi(ctx, organizationID, &response.Diagnostics) 29 | if response.Diagnostics.HasError() { 30 | return 31 | } 32 | 33 | response.State.Set(ctx, &result) 34 | } 35 | -------------------------------------------------------------------------------- /ec/ecresource/organizationresource/list_difference.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package organizationresource 19 | 20 | // Returns all the elements from array a that are not in array b 21 | func difference[T interface{}](a, b []*T, getKey func(T) string) []*T { 22 | var diff []*T 23 | m := make(map[string]T) 24 | for _, item := range b { 25 | if item == nil { 26 | continue 27 | } 28 | key := getKey(*item) 29 | m[key] = *item 30 | } 31 | 32 | for _, item := range a { 33 | if item == nil { 34 | continue 35 | } 36 | key := getKey(*item) 37 | if _, ok := m[key]; !ok { 38 | diff = append(diff, item) 39 | } 40 | } 41 | 42 | return diff 43 | } 44 | -------------------------------------------------------------------------------- /ec/ecresource/organizationresource/mapper_roles.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package organizationresource 19 | 20 | import "strings" 21 | 22 | type RoleType string 23 | 24 | const ( 25 | deployment = "deployment" 26 | projectElasticsearch = "elasticsearch" 27 | projectObservability = "observability" 28 | projectSecurity = "security" 29 | ) 30 | 31 | // Adds the prefix to a role (e.g. admin -> elasticsearch-admin) 32 | func roleModelToApi(modelRole string, roleType RoleType) *string { 33 | apiRole := string(roleType) + "-" + modelRole 34 | return &apiRole 35 | } 36 | 37 | // Removes the prefix from a role (e.g. elasticsearch-admin -> admin) 38 | func roleApiToModel(apiRole string, roleType RoleType) string { 39 | return strings.TrimPrefix(apiRole, string(roleType)+"-") 40 | } 41 | -------------------------------------------------------------------------------- /ec/ecresource/organizationresource/resource.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package organizationresource 19 | 20 | import ( 21 | "context" 22 | "github.com/elastic/cloud-sdk-go/pkg/api" 23 | "github.com/elastic/terraform-provider-ec/ec/internal" 24 | "github.com/hashicorp/terraform-plugin-framework/resource" 25 | ) 26 | 27 | type Resource struct { 28 | client *api.API 29 | } 30 | 31 | var _ resource.Resource = &Resource{} 32 | var _ resource.ResourceWithConfigure = &Resource{} 33 | var _ resource.ResourceWithImportState = &Resource{} 34 | 35 | func (r *Resource) Metadata(ctx context.Context, request resource.MetadataRequest, response *resource.MetadataResponse) { 36 | response.TypeName = request.ProviderTypeName + "_organization" 37 | } 38 | 39 | func (r *Resource) Configure(ctx context.Context, request resource.ConfigureRequest, response *resource.ConfigureResponse) { 40 | client, diags := internal.ConvertProviderData(request.ProviderData) 41 | response.Diagnostics.Append(diags...) 42 | r.client = client.Stateful 43 | } 44 | -------------------------------------------------------------------------------- /ec/ecresource/projectresource/delete.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package projectresource 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/resource" 24 | ) 25 | 26 | func (r *Resource[T]) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { 27 | if !resourceReady(r, &response.Diagnostics) { 28 | return 29 | } 30 | 31 | model, diags := r.modelHandler.ReadFrom(ctx, request.State) 32 | response.Diagnostics.Append(diags...) 33 | if response.Diagnostics.HasError() { 34 | return 35 | } 36 | 37 | response.Diagnostics.Append(r.api.Delete(ctx, *model)...) 38 | if response.Diagnostics.HasError() { 39 | return 40 | } 41 | 42 | response.State.RemoveResource(ctx) 43 | } 44 | -------------------------------------------------------------------------------- /ec/ecresource/trafficfilterassocresource/update.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package trafficfilterassocresource 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/resource" 24 | ) 25 | 26 | func (r Resource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { 27 | panic("ec_deployment_traffic_filter_association resources can not be updated!") 28 | } 29 | -------------------------------------------------------------------------------- /ec/internal/gen/serverless/client-config.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=../../configuration-schema.json 2 | package: serverless 3 | output: client.gen.go 4 | generate: 5 | models: true 6 | client: true 7 | -------------------------------------------------------------------------------- /ec/internal/gen/serverless/modify_spec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/env bash 2 | 3 | jq --slurpfile plan_modifiers string_use_state_for_unknown.json 'def applies_to($item): $plan_modifiers[0].applies_to[] | any(. == $item; .); (.resources[] | .schema.attributes[] | select(applies_to(.name))).string.plan_modifiers |= $plan_modifiers[0].add' spec.json > /tmp/with-strings.json 4 | 5 | mv /tmp/with-strings.json ./spec-mod.json 6 | -------------------------------------------------------------------------------- /ec/internal/gen/serverless/oapi-config.yaml: -------------------------------------------------------------------------------- 1 | provider: 2 | name: ec 3 | resources: 4 | elasticsearch_project: 5 | create: 6 | path: /api/v1/serverless/projects/elasticsearch 7 | method: post 8 | read: 9 | path: /api/v1/serverless/projects/elasticsearch/{id} 10 | method: get 11 | update: 12 | path: /api/v1/serverless/projects/elasticsearch/{id} 13 | method: patch 14 | delete: 15 | path: /api/v1/serverless/projects/elasticsearch/{id} 16 | method: delete 17 | observability_project: 18 | create: 19 | path: /api/v1/serverless/projects/observability 20 | method: post 21 | read: 22 | path: /api/v1/serverless/projects/observability/{id} 23 | method: get 24 | update: 25 | path: /api/v1/serverless/projects/observability/{id} 26 | method: patch 27 | delete: 28 | path: /api/v1/serverless/projects/observability/{id} 29 | method: delete 30 | security_project: 31 | create: 32 | path: /api/v1/serverless/projects/security 33 | method: post 34 | read: 35 | path: /api/v1/serverless/projects/security/{id} 36 | method: get 37 | update: 38 | path: /api/v1/serverless/projects/security/{id} 39 | method: patch 40 | delete: 41 | path: /api/v1/serverless/projects/security/{id} 42 | method: delete 43 | -------------------------------------------------------------------------------- /ec/internal/gen/serverless/provider_ec/ec_provider_gen.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | // Code generated by terraform-plugin-framework-generator DO NOT EDIT. 19 | 20 | package provider_ec 21 | 22 | import ( 23 | "context" 24 | 25 | "github.com/hashicorp/terraform-plugin-framework/provider/schema" 26 | ) 27 | 28 | func EcProviderSchema(ctx context.Context) schema.Schema { 29 | return schema.Schema{} 30 | } 31 | 32 | type EcModel struct { 33 | } 34 | -------------------------------------------------------------------------------- /ec/internal/gen/serverless/serverless.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | //go:generate go run github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi generate --config oapi-config.yaml --output spec.json serverless-project-api-dereferenced.yml 19 | //go:generate sh modify_spec.sh 20 | //go:generate go run github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework generate all --input spec-mod.json --output . 21 | //go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=client-config.yaml serverless-project-api-dereferenced.yml 22 | //go:generate go run go.uber.org/mock/mockgen -destination=mocks/client.gen.go -package mocks . ClientWithResponsesInterface,ClientInterface 23 | package serverless 24 | -------------------------------------------------------------------------------- /ec/internal/gen/serverless/string_use_state_for_unknown.json: -------------------------------------------------------------------------------- 1 | { 2 | "applies_to": [ 3 | "alias", 4 | "cloud_id", 5 | "id", 6 | "type", 7 | "optimized_for" 8 | ], 9 | "add": [ 10 | { 11 | "custom": { 12 | "imports": [ 13 | { 14 | "path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" 15 | } 16 | ], 17 | "schema_definition": "stringplanmodifier.UseStateForUnknown()" 18 | } 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /ec/internal/planmodifiers/attribute_changed.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package planmodifiers 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/attr" 24 | "github.com/hashicorp/terraform-plugin-framework/diag" 25 | "github.com/hashicorp/terraform-plugin-framework/path" 26 | "github.com/hashicorp/terraform-plugin-framework/tfsdk" 27 | ) 28 | 29 | func AttributeChanged(ctx context.Context, p path.Path, plan tfsdk.Plan, state tfsdk.State) (bool, diag.Diagnostics) { 30 | var planValue attr.Value 31 | 32 | if diags := plan.GetAttribute(ctx, p, &planValue); diags.HasError() { 33 | return false, diags 34 | } 35 | 36 | var stateValue attr.Value 37 | 38 | if diags := state.GetAttribute(ctx, p, &stateValue); diags.HasError() { 39 | return false, diags 40 | } 41 | 42 | return !planValue.Equal(stateValue), nil 43 | } 44 | -------------------------------------------------------------------------------- /ec/internal/planmodifiers/has_attribute.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package planmodifiers 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/attr" 24 | "github.com/hashicorp/terraform-plugin-framework/diag" 25 | "github.com/hashicorp/terraform-plugin-framework/path" 26 | "github.com/hashicorp/terraform-plugin-framework/tfsdk" 27 | ) 28 | 29 | func HasAttribute(ctx context.Context, p path.Path, plan tfsdk.Plan) (bool, diag.Diagnostics) { 30 | var value attr.Value 31 | 32 | if diags := plan.GetAttribute(ctx, p, &value); diags.HasError() { 33 | return false, diags 34 | } 35 | 36 | return !value.IsNull(), nil 37 | } 38 | -------------------------------------------------------------------------------- /ec/internal/planmodifiers/state_attribute_defined.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package planmodifiers 19 | 20 | import ( 21 | "context" 22 | 23 | "github.com/hashicorp/terraform-plugin-framework/attr" 24 | "github.com/hashicorp/terraform-plugin-framework/diag" 25 | "github.com/hashicorp/terraform-plugin-framework/path" 26 | "github.com/hashicorp/terraform-plugin-framework/tfsdk" 27 | ) 28 | 29 | func AttributeStateDefined(ctx context.Context, p path.Path, state tfsdk.State) (bool, diag.Diagnostics) { 30 | var val attr.Value 31 | 32 | if diags := state.GetAttribute(ctx, p, &val); diags.HasError() { 33 | return false, diags 34 | } 35 | 36 | return !val.IsNull() && !val.IsUnknown(), nil 37 | } 38 | -------------------------------------------------------------------------------- /ec/internal/util/parsers.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package util 19 | 20 | import ( 21 | "fmt" 22 | ) 23 | 24 | // MemoryToState parses a megabyte int notation to a gigabyte notation. 25 | func MemoryToState(mem int32) string { 26 | if mem%1024 > 1 && mem%512 == 0 { 27 | return fmt.Sprintf("%0.1fg", float32(mem)/1024) 28 | } 29 | return fmt.Sprintf("%dg", mem/1024) 30 | } 31 | 32 | func MemoryToStateOptional(mem *int32) *string { 33 | if mem == nil { 34 | return nil 35 | } 36 | result := MemoryToState(*mem) 37 | return &result 38 | } 39 | -------------------------------------------------------------------------------- /ec/internal/util/parsers_test.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package util 19 | 20 | import ( 21 | "testing" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestMemoryToState(t *testing.T) { 27 | type args struct { 28 | mem int32 29 | } 30 | tests := []struct { 31 | name string 32 | args args 33 | want string 34 | }{ 35 | { 36 | name: "gigabytes", 37 | args: args{mem: 4096}, 38 | want: "4g", 39 | }, 40 | { 41 | name: "512 megabytes turns into 0.5g", 42 | args: args{mem: 512}, 43 | want: "0.5g", 44 | }, 45 | } 46 | for _, tt := range tests { 47 | t.Run(tt.name, func(t *testing.T) { 48 | got := MemoryToState(tt.args.mem) 49 | assert.Equal(t, tt.want, got) 50 | }) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ec/internal/util/resource_kind.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package util 19 | 20 | type ResourceKind int 21 | 22 | const ( 23 | ApmResourceKind ResourceKind = iota 24 | ElasticsearchResourceKind 25 | EnterpriseSearchResourceKind 26 | IntegrationsServerResourceKind 27 | KibanaResourceKind 28 | ) 29 | 30 | func (rk ResourceKind) Name() string { 31 | switch rk { 32 | case ApmResourceKind: 33 | return "APM" 34 | case ElasticsearchResourceKind: 35 | return "Elasticsearch" 36 | case EnterpriseSearchResourceKind: 37 | return "Enterprise Search" 38 | case IntegrationsServerResourceKind: 39 | return "Integrations Server" 40 | case KibanaResourceKind: 41 | return "Kibana" 42 | default: 43 | return "unknown" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ec/internal/util/traffic_filter_err.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package util 19 | 20 | import ( 21 | "errors" 22 | "net/http" 23 | 24 | "github.com/elastic/cloud-sdk-go/pkg/api/apierror" 25 | "github.com/elastic/cloud-sdk-go/pkg/client/deployments_traffic_filter" 26 | ) 27 | 28 | // TrafficFilterNotFound returns true when the error is a 404 or 403. 29 | func TrafficFilterNotFound(err error) bool { 30 | // We're using the As() call since we do not care about the error value 31 | // but do care about the error type since it's an implicit 404. 32 | var notDeploymentNotFound *deployments_traffic_filter.GetTrafficFilterRulesetNotFound 33 | if errors.As(err, ¬DeploymentNotFound) { 34 | return true 35 | } 36 | 37 | // We also check for the case where a 403 is thrown for ESS. 38 | return apierror.IsRuntimeStatusCode(err, http.StatusForbidden) 39 | } 40 | -------------------------------------------------------------------------------- /ec/requests.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/terraform-provider-ec/9507fdf3e2b13b64d0db488b420cadc12be8f195/ec/requests.log -------------------------------------------------------------------------------- /ec/version.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | package ec 19 | 20 | // Version contains the current terraform provider version. 21 | const Version = "0.12.2-dev" 22 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Elastic Cloud provider examples 2 | 3 | This directory contains a set of examples that show you how to use Elastic Cloud resources with Terraform. For each example there is a README file with a detailed description. 4 | 5 | To run any example, clone the repository. Build the provider using `make install` from the main folder. From within the example's directory, run `terraform init` to initialize Terraform, and `terraform apply` to apply the changes. 6 | -------------------------------------------------------------------------------- /examples/data-sources/ec_aws_privatelink_endpoint/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_aws_privatelink_endpoint" "us-east-1" { 2 | region = "us-east-1" 3 | } 4 | -------------------------------------------------------------------------------- /examples/data-sources/ec_azure_privatelink_endpoint/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_azure_privatelink_endpoint" "eastus" { 2 | region = "eastus" 3 | } 4 | -------------------------------------------------------------------------------- /examples/data-sources/ec_deployment/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_deployment" "example" { 2 | id = "f759065e5e64e9f3546f6c44f2743893" 3 | } 4 | -------------------------------------------------------------------------------- /examples/data-sources/ec_deployment_templates/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_deployment_templates" "example" { 2 | region = "us-east-1" 3 | } 4 | 5 | resource "ec_deployment" "my_deployment" { 6 | name = "My Deployment" 7 | version = "8.12.2" 8 | region = data.ec_deployment_templates.all_templates.region 9 | deployment_template_id = data.ec_deployment_templates.all_templates.templates.0.id 10 | 11 | elasticsearch = { 12 | hot = { 13 | autoscaling = {} 14 | } 15 | } 16 | 17 | kibana = {} 18 | } -------------------------------------------------------------------------------- /examples/data-sources/ec_deployments/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_deployments" "example" { 2 | name_prefix = "test" 3 | deployment_template_id = "azure-compute-optimized" 4 | 5 | size = 200 6 | 7 | tags = { 8 | "foo" = "bar" 9 | } 10 | 11 | elasticsearch { 12 | healthy = "true" 13 | } 14 | 15 | kibana { 16 | status = "started" 17 | } 18 | 19 | integrations_server { 20 | version = "8.0.0" 21 | } 22 | 23 | enterprise_search { 24 | healthy = "true" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/data-sources/ec_gcp_private_service_connect_endpoint/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_gcp_private_service_connect_endpoint" "us-central1" { 2 | region = "us-central1" 3 | } 4 | -------------------------------------------------------------------------------- /examples/data-sources/ec_stack/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "us-east-1" 4 | lock = true 5 | } 6 | 7 | data "ec_stack" "latest_patch" { 8 | version_regex = "7.9.?" 9 | region = "us-east-1" 10 | } 11 | -------------------------------------------------------------------------------- /examples/data-sources/ec_traffic_filter/data-source.tf: -------------------------------------------------------------------------------- 1 | data "ec_traffic_filter" "name" { 2 | name = "example-filter" 3 | } 4 | 5 | data "ec_traffic_filter" "id" { 6 | id = "41d275439f884ce89359039e53eac516" 7 | } 8 | 9 | data "ec_traffic_filter" "region" { 10 | region = "us-east-1" 11 | } 12 | -------------------------------------------------------------------------------- /examples/deployment_ccs/README.md: -------------------------------------------------------------------------------- 1 | # Deployment Example 2 | 3 | This example shows how to deploy multiple Elastic Cloud deployments, and reference one another through Cross Cluster Search using Terraform only. 4 | The example creates two single node Elasticsearch clusters acting as sources for another Elasticsearch deployment with Cross Cluster Search enabled. 5 | 6 | ## Running the example 7 | 8 | Build the provider using `make install` from the main folder. From within the example's directory, run `terraform init` to initialize Terraform, and `terraform apply` to apply the changes. 9 | -------------------------------------------------------------------------------- /examples/deployment_ccs/outputs.tf: -------------------------------------------------------------------------------- 1 | output "deployment_id" { 2 | value = ec_deployment.ccs.id 3 | } 4 | 5 | output "elasticsearch_version" { 6 | value = ec_deployment.ccs.version 7 | } 8 | 9 | output "elasticsearch_cloud_id" { 10 | value = ec_deployment.ccs.elasticsearch[0].cloud_id 11 | } 12 | 13 | output "elasticsearch_https_endpoint" { 14 | value = ec_deployment.ccs.elasticsearch[0].https_endpoint 15 | } 16 | 17 | output "elasticsearch_username" { 18 | value = ec_deployment.ccs.elasticsearch_username 19 | } 20 | 21 | output "elasticsearch_password" { 22 | value = ec_deployment.ccs.elasticsearch_password 23 | } 24 | -------------------------------------------------------------------------------- /examples/deployment_ec2_instance/README.md: -------------------------------------------------------------------------------- 1 | # Deployment with an EC2 Instance example 2 | 3 | This example shows how to build an application's infrastructure using EC2 instances and an Elastic Cloud deployment, while communicating securely using traffic filters. 4 | The code creates an EC2 instance in your default VPC and subnet, but uses the instance's public IP address to configure a traffic filter connecting it back to the Elastic Cloud deployment. 5 | Such communication can also be done through this Terraform provider using AWS PrivateLink. 6 | 7 | ## Running the example 8 | To run the example, follow these steps: 9 | 1. Build the provider by running `make install` from the main folder. 10 | 2. Run `terrafrom init` to initialize your Terraform CLI. 11 | 3. Modify the `variables.tf` file to add your AWS profile and Elastic cloud key. 12 | 4. Run `terraform apply` to check if it works. 13 | -------------------------------------------------------------------------------- /examples/deployment_ec2_instance/aws_ec2.tf: -------------------------------------------------------------------------------- 1 | resource "aws_instance" "web" { 2 | ami = var.ubuntu18_ami 3 | instance_type = "t2.large" 4 | vpc_security_group_ids = [aws_security_group.group.id] 5 | key_name = var.keypair 6 | subnet_id = aws_default_subnet.default.id 7 | } 8 | 9 | # Use the default VPC and subnet 10 | resource "aws_default_vpc" "default" {} 11 | resource "aws_default_subnet" "default" { 12 | # Use zone A for convenience. This would render as us-east-1a, in case us-east-1 is the region variable. 13 | availability_zone = format("%sa", var.region) 14 | } 15 | 16 | # Create a security group to allow all outbound (egress) and SSH inbound (ingress) traffic. 17 | resource "aws_security_group" "group" { 18 | vpc_id = aws_default_vpc.default.id 19 | egress { 20 | from_port = 0 21 | protocol = "-1" 22 | to_port = 0 23 | cidr_blocks = ["0.0.0.0/0"] 24 | } 25 | 26 | ingress { 27 | from_port = 22 28 | protocol = "tcp" 29 | to_port = 22 30 | cidr_blocks = ["0.0.0.0/0"] 31 | } 32 | } 33 | 34 | output "instance" { 35 | value = aws_instance.web.public_ip 36 | } 37 | -------------------------------------------------------------------------------- /examples/deployment_ec2_instance/elastic_deployment.tf: -------------------------------------------------------------------------------- 1 | # Retrieve the latest stack pack version 2 | data "ec_stack" "latest" { 3 | version_regex = "latest" 4 | region = var.region 5 | } 6 | 7 | # Create an Elastic Cloud deployment 8 | resource "ec_deployment" "deployment" { 9 | # Optional name. 10 | name = "elasticsearch_deployment" 11 | 12 | # Mandatory fields. 13 | region = var.region 14 | version = data.ec_stack.latest.version 15 | deployment_template_id = "aws-io-optimized-v2" 16 | traffic_filter = [ec_deployment_traffic_filter.allow_my_instance.id] 17 | 18 | # Note the deployment will contain Elasticsearch and Kibana resources with default configurations. 19 | elasticsearch = { 20 | config = {} 21 | hot = { 22 | autoscaling = {} 23 | } 24 | } 25 | 26 | kibana = {} 27 | } 28 | 29 | # Create a traffic filter to allow the instance's public IP address to access our deployment. 30 | # This can also be done using a VPC private link connection. 31 | resource "ec_deployment_traffic_filter" "allow_my_instance" { 32 | name = format("Allow %s", aws_instance.web.id) 33 | region = var.region 34 | type = "ip" 35 | 36 | rule { 37 | # Render the IP address with an additional /32 for full CIDR address. 38 | source = format("%s/32", aws_instance.web.public_ip) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/deployment_ec2_instance/provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.12.29" 3 | 4 | required_providers { 5 | ec = { 6 | source = "elastic/ec" 7 | version = "0.12.2" 8 | } 9 | 10 | aws = { 11 | source = "hashicorp/aws" 12 | version = "~> 5.45, != 5.71.0" 13 | } 14 | } 15 | } 16 | 17 | provider "ec" { 18 | apikey = var.ec_api_key 19 | } 20 | 21 | provider "aws" { 22 | region = var.region 23 | profile = var.aws_profile 24 | } 25 | -------------------------------------------------------------------------------- /examples/deployment_ec2_instance/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | default = "us-east-1" 3 | } 4 | 5 | variable "aws_profile" { 6 | default = "" 7 | } 8 | 9 | variable "ec_api_key" { 10 | default = "" 11 | } 12 | 13 | variable "keypair" { 14 | default = "" 15 | } 16 | 17 | variable "ubuntu18_ami" { 18 | # This AMI ID is only valid for us-east-1. 19 | default = "ami-0817d428a6fb68645" 20 | } 21 | -------------------------------------------------------------------------------- /examples/deployment_with_init/README.md: -------------------------------------------------------------------------------- 1 | # Deployment example 2 | 3 | This example shows how to deploy an Elastic Cloud deployment using Terraform. 4 | First, you initialize the instance by using some of the outputs as string variables within a bash script to create a user and an index. 5 | Then, you create a traffic filter (which allows all traffic) and attach it to the deployment. 6 | 7 | ## Running the example 8 | 9 | To run the example, follow these steps: 10 | 11 | 1. Build the provider by running `make install` from the main folder. 12 | 2. Run `terrafrom init` to initialize your Terraform CLI. 13 | 3. Run `terraform apply` to see how it works. 14 | -------------------------------------------------------------------------------- /examples/deployment_with_init/deployment.tf: -------------------------------------------------------------------------------- 1 | # Retrieve the latest stack pack version 2 | data "ec_stack" "latest" { 3 | version_regex = "latest" 4 | region = "us-east-1" 5 | } 6 | 7 | # Create an Elastic Cloud deployment 8 | resource "ec_deployment" "example_minimal" { 9 | # Optional name. 10 | name = "my_example_deployment" 11 | 12 | # Mandatory fields 13 | region = "us-east-1" 14 | version = data.ec_stack.latest.version 15 | deployment_template_id = "aws-io-optimized-v2" 16 | traffic_filter = [ec_deployment_traffic_filter.allow_all.id] 17 | elasticsearch = { 18 | config = {} 19 | hot = { 20 | size = "8g" 21 | autoscaling = {} 22 | } 23 | } 24 | 25 | kibana = { 26 | size = "1g" 27 | } 28 | } 29 | 30 | resource "ec_deployment_traffic_filter" "allow_all" { 31 | name = "Allow all ip addresses" 32 | region = "us-east-1" 33 | type = "ip" 34 | 35 | rule { 36 | source = "0.0.0.0/0" 37 | } 38 | } 39 | 40 | output "elasticsearch_https_endpoint" { 41 | value = ec_deployment.example_minimal.elasticsearch[0].https_endpoint 42 | } 43 | 44 | output "elasticsearch_username" { 45 | value = ec_deployment.example_minimal.elasticsearch_username 46 | } 47 | 48 | output "elasticsearch_password" { 49 | value = ec_deployment.example_minimal.elasticsearch_password 50 | } 51 | 52 | output "elasticsearch_cloud_id" { 53 | value = ec_deployment.example_minimal.elasticsearch[0].cloud_id 54 | } 55 | -------------------------------------------------------------------------------- /examples/deployment_with_init/es_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | log (){ 4 | echo "\n######## $1 ########\n" 5 | } 6 | 7 | create_users() { 8 | # Create a personal superuser 9 | log "creating additional superuser" 10 | curl -s --user ${elastic-user}:${elastic-password} -XPOST ${es-url}/_security/user/omer -d\ 11 | '{"password" : "Password1","roles" : [ "superuser"],"full_name" : "Omer Kushmaro","email" : "omer.kushmaro@elastic.co"}'\ 12 | -H 'Accept: application/json' -H 'Content-type: application/json' 13 | 14 | # Create an ingest user 15 | log "creating an ingest user" 16 | curl -s --user ${elastic-user}:${elastic-password} -XPOST ${es-url}/_security/user/filebeat -d\ 17 | '{"password" : "Ingest123!","roles" : [ "ingest_admin"],"full_name" : "File Beat","email" : "application@elastic.co"}'\ 18 | -H 'Accept: application/json' -H 'Content-type: application/json' 19 | } 20 | 21 | create_indices() { 22 | # Creating my importnat index and mapping 23 | log "creating pre-defined index and mapping" 24 | curl -s --user ${elastic-user}:${elastic-password} -XPUT ${es-url}/my-index-000001 -d\ 25 | '{"settings": {"number_of_shards": 2,"number_of_replicas": 2},"mappings": {"properties": {"field1": { "type": "text" }}}}'\ 26 | -H 'Accept: application/json' -H 'Content-type: application/json' 27 | } 28 | 29 | _main() { 30 | create_indices 31 | create_users 32 | } 33 | 34 | _main "$@" -------------------------------------------------------------------------------- /examples/deployment_with_init/main.tf: -------------------------------------------------------------------------------- 1 | resource "null_resource" "bootstrap-elasticsearch" { 2 | provisioner "local-exec" { 3 | # Created servers and appropriate AZs 4 | command = templatefile("es_config.sh", { 5 | elastic-user = ec_deployment.example_minimal.elasticsearch_username 6 | elastic-password = ec_deployment.example_minimal.elasticsearch_password 7 | es-url = ec_deployment.example_minimal.elasticsearch[0].https_endpoint 8 | }) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/deployment_with_init/provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | 4 | required_providers { 5 | ec = { 6 | source = "elastic/ec" 7 | version = "0.12.2" 8 | } 9 | } 10 | } 11 | 12 | provider "ec" { 13 | apikey = "" 14 | } 15 | 16 | -------------------------------------------------------------------------------- /examples/extension_bundle/README.md: -------------------------------------------------------------------------------- 1 | # Extension Bundle example 2 | 3 | This example shows how to create an Elastic Cloud bundle extension using Terraform. 4 | 5 | The bundle extension is created with `files/content.json` uploaded. 6 | 7 | See https://www.elastic.co/guide/en/cloud/current/ec-custom-bundles.html#ec-add-your-plugin for details. 8 | 9 | ## Running the example 10 | 11 | To run the example, follow these steps: 12 | 13 | 1. Build the provider by running `make install` from the main folder. 14 | 2. Run `terrafrom init` to initialize your Terraform CLI. 15 | 3. Run `terraform apply` to see how it works. 16 | -------------------------------------------------------------------------------- /examples/extension_bundle/extension.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 1.0" 3 | 4 | required_providers { 5 | ec = { 6 | source = "elastic/ec" 7 | version = "0.12.2" 8 | } 9 | } 10 | } 11 | 12 | provider "ec" {} 13 | 14 | locals { 15 | file_path = "./files/content.json.zip" 16 | } 17 | 18 | # Create an Elastic Cloud Extension 19 | resource "ec_deployment_extension" "example_extension" { 20 | name = "my_extension" 21 | description = "my extension" 22 | version = "*" 23 | extension_type = "bundle" 24 | 25 | file_path = local.file_path 26 | file_hash = filebase64sha256(local.file_path) 27 | } 28 | -------------------------------------------------------------------------------- /examples/extension_bundle/files/content.json: -------------------------------------------------------------------------------- 1 | {"foo": "value", "bar": 3} -------------------------------------------------------------------------------- /examples/extension_bundle/files/content.json.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/terraform-provider-ec/9507fdf3e2b13b64d0db488b420cadc12be8f195/examples/extension_bundle/files/content.json.zip -------------------------------------------------------------------------------- /examples/extension_bundle/outputs.tf: -------------------------------------------------------------------------------- 1 | output "extension_id" { 2 | value = ec_deployment_extension.example_extension.id 3 | } 4 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/basic/deployment.tf: -------------------------------------------------------------------------------- 1 | # Retrieve the latest stack pack version 2 | data "ec_stack" "latest" { 3 | version_regex = "latest" 4 | region = "us-east-1" 5 | } 6 | 7 | # Create an Elastic Cloud deployment 8 | resource "ec_deployment" "example_minimal" { 9 | # Optional name. 10 | name = "my_example_deployment" 11 | 12 | region = "us-east-1" 13 | version = data.ec_stack.latest.version 14 | deployment_template_id = "aws-io-optimized-v2" 15 | 16 | elasticsearch = { 17 | hot = { 18 | autoscaling = {} 19 | } 20 | } 21 | 22 | kibana = {} 23 | 24 | enterprise_search = {} 25 | 26 | integrations_server = {} 27 | } 28 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/import.sh: -------------------------------------------------------------------------------- 1 | terraform import ec_deployment.search 320b7b540dfc967a7a649c18e2fce4ed 2 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/with-autoscaling/deployment.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "us-east-1" 4 | } 5 | 6 | resource "ec_deployment" "example_minimal" { 7 | region = "us-east-1" 8 | version = data.ec_stack.latest.version 9 | deployment_template_id = "aws-io-optimized-v2" 10 | 11 | elasticsearch = { 12 | 13 | autoscale = "true" 14 | 15 | # If `autoscale` is set, all topology elements that 16 | # - either set `size` in the plan or 17 | # - have non-zero default `max_size` (that is read from the deployment templates's `autoscaling_max` value) 18 | # have to be listed even if their blocks don't specify other fields beside `id` 19 | 20 | cold = { 21 | autoscaling = {} 22 | } 23 | 24 | frozen = { 25 | autoscaling = {} 26 | } 27 | 28 | hot = { 29 | size = "8g" 30 | 31 | autoscaling = { 32 | max_size = "128g" 33 | max_size_resource = "memory" 34 | } 35 | } 36 | 37 | ml = { 38 | autoscaling = {} 39 | } 40 | 41 | warm = { 42 | autoscaling = {} 43 | } 44 | } 45 | 46 | # Initial size for `hot_content` tier is set to 8g 47 | # so `hot_content`'s size has to be added to the `ignore_changes` meta-argument to ignore future modifications that can be made by the autoscaler 48 | lifecycle { 49 | ignore_changes = [ 50 | elasticsearch.hot.size 51 | ] 52 | } 53 | 54 | kibana = {} 55 | 56 | integrations_server = {} 57 | 58 | enterprise_search = {} 59 | } 60 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/with-ccs/deployment.tf: -------------------------------------------------------------------------------- 1 | data "ec_stack" "latest" { 2 | version_regex = "latest" 3 | region = "us-east-1" 4 | } 5 | 6 | resource "ec_deployment" "source_deployment" { 7 | name = "my_ccs_source" 8 | 9 | region = "us-east-1" 10 | version = data.ec_stack.latest.version 11 | deployment_template_id = "aws-io-optimized-v2" 12 | 13 | elasticsearch = { 14 | hot = { 15 | size = "1g" 16 | autoscaling = {} 17 | } 18 | } 19 | } 20 | 21 | resource "ec_deployment" "ccs" { 22 | name = "ccs deployment" 23 | 24 | region = "us-east-1" 25 | version = data.ec_stack.latest.version 26 | deployment_template_id = "aws-cross-cluster-search-v2" 27 | 28 | elasticsearch = { 29 | hot = { 30 | autoscalign = {} 31 | } 32 | remote_cluster = [{ 33 | deployment_id = ec_deployment.source_deployment.id 34 | alias = ec_deployment.source_deployment.name 35 | ref_id = ec_deployment.source_deployment.elasticsearch.0.ref_id 36 | }] 37 | } 38 | 39 | kibana = {} 40 | } 41 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/with-config/deployment.tf: -------------------------------------------------------------------------------- 1 | # Retrieve the latest stack pack version 2 | data "ec_stack" "latest" { 3 | version_regex = "latest" 4 | region = "us-east-1" 5 | } 6 | 7 | # Create an Elastic Cloud deployment 8 | resource "ec_deployment" "example_minimal" { 9 | # Optional name. 10 | name = "my_example_deployment" 11 | 12 | region = "us-east-1" 13 | version = data.ec_stack.latest.version 14 | deployment_template_id = "aws-io-optimized-v2" 15 | 16 | elasticsearch = { 17 | hot = { 18 | autoscaling = {} 19 | } 20 | config = { 21 | user_settings_yaml = file("./es.yaml") 22 | } 23 | } 24 | 25 | kibana = {} 26 | 27 | enterprise_search = {} 28 | 29 | integrations_server = {} 30 | } 31 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/with-config/es.yaml: -------------------------------------------------------------------------------- 1 | # My example YAML configuration for elasicsearch nodes 2 | repositories.url.allowed_urls: ["http://www.example.org/root/*", "https://*.mydomain.com/*?*#*"] 3 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/with-config/outputs.tf: -------------------------------------------------------------------------------- 1 | output "elasticsearch_version" { 2 | value = ec_deployment.example_minimal.version 3 | } 4 | 5 | output "elasticsearch_cloud_id" { 6 | value = ec_deployment.example_minimal.elasticsearch.cloud_id 7 | } 8 | 9 | output "elasticsearch_https_endpoint" { 10 | value = ec_deployment.example_minimal.elasticsearch.https_endpoint 11 | } 12 | 13 | output "elasticsearch_username" { 14 | value = ec_deployment.example_minimal.elasticsearch_username 15 | } 16 | 17 | output "elasticsearch_password" { 18 | value = ec_deployment.example_minimal.elasticsearch_password 19 | sensitive = true 20 | } 21 | -------------------------------------------------------------------------------- /examples/resources/ec_deployment/with-keystore/deployment.tf: -------------------------------------------------------------------------------- 1 | # Retrieve the latest stack pack version 2 | data "ec_stack" "latest" { 3 | version_regex = "latest" 4 | region = "us-east-1" 5 | } 6 | 7 | # Create an Elastic Cloud deployment with keystore 8 | resource "ec_deployment" "with_keystore" { 9 | name = "example_with_keystore" 10 | 11 | region = "us-east-1" 12 | version = data.ec_stack.latest.version 13 | deployment_template_id = "aws-io-optimized-v2" 14 | 15 | elasticsearch = { 16 | hot = { 17 | autoscaling = {} 18 | } 19 | 20 | config = { 21 | user_settings_yaml = <" 25 | rp.response_type: "code" 26 | rp.requested_scopes: ["openid", "email"] 27 | rp.redirect_uri: "/api/security/oidc/callback" 28 | op.issuer: "" 29 | op.authorization_endpoint: "/oauth2/v1/authorize" 30 | op.token_endpoint: "/oauth2/v1/token" 31 | op.userinfo_endpoint: "/oauth2/v1/userinfo" 32 | op.endsession_endpoint: "/oauth2/v1/logout" 33 | op.jwkset_path: "/oauth2/v1/keys" 34 | claims.principal: email 35 | claim_patterns.principal: "^([^@]+)@elastic\\.co$" 36 | EOF 37 | } 38 | 39 | keystore_contents = { 40 | "xpack.security.authc.realms.oidc.oidc1.rp.client_secret" = { 41 | value = "secret-1" 42 | } 43 | } 44 | } 45 | 46 | kibana = { 47 | zone_count = 1 48 | config = { 49 | user_settings_yaml = <&2 34 | sleep $wait 35 | else 36 | printf "Retry %s/%s exited %s, no more retries left.\n" "$count" "$retries" "$exit" >&2 37 | return $exit 38 | fi 39 | done 40 | return 0 41 | } 42 | 43 | retry "$@" 44 | -------------------------------------------------------------------------------- /scripts/uname_arch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | arch=$(uname -m) 4 | case $arch in 5 | x86_64) arch="amd64" ;; 6 | x86) arch="386" ;; 7 | i686) arch="386" ;; 8 | i386) arch="386" ;; 9 | aarch64) arch="arm64" ;; 10 | armv5*) arch="armv5" ;; 11 | armv6*) arch="armv6" ;; 12 | armv7*) arch="armv7" ;; 13 | esac 14 | echo ${arch} 15 | -------------------------------------------------------------------------------- /scripts/uname_arch_goreleaser.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | arch=$(uname -m) 4 | case $arch in 5 | x86_64) arch="x86_64" ;; 6 | x86) arch="i386" ;; 7 | i686) arch="i386" ;; 8 | i386) arch="i386" ;; 9 | aarch64) arch="arm64" ;; 10 | armv5*) arch="armv5" ;; 11 | armv6*) arch="armv6" ;; 12 | armv7*) arch="armv7" ;; 13 | esac 14 | echo ${arch} 15 | -------------------------------------------------------------------------------- /scripts/update-provider-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # This script takes in a single parameter with the current provider version 5 | # and updates all the files that contain a declaration of the 'ec' provider 6 | # to use the current version. 7 | # 8 | 9 | set -e 10 | 11 | echo "-> Updating the version field on references to the previous 'ec' provider declaration" 12 | 13 | declare -a UPDATE_FILES=("README.md") 14 | for f in $(grep -R 'ec = {' examples | cut -d : -f1); do 15 | UPDATE_FILES+=("$f") 16 | done 17 | 18 | for f in "${UPDATE_FILES[@]}"; do 19 | # Instead of using the -i flag which its implementation differs on macOS and 20 | # Linux, save the output in the temporary folder and move the result over to 21 | # the original file for better OS cross-compatibility. 22 | FILE_NAME="$(basename $f)" 23 | sed "s/ version = \".*\"/ version = \"${1}\"/" $f > /tmp/$FILE_NAME 24 | mv /tmp/$FILE_NAME $f 25 | done 26 | 27 | echo "-> Updated all the ec provider declarations" 28 | -------------------------------------------------------------------------------- /scripts/validate_examples.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | EXAMPLES=$(find examples -maxdepth 1 -type d | grep "/") 6 | BASEPATH=$(pwd) 7 | 8 | for example in ${EXAMPLES}; do 9 | cd ${BASEPATH}/${example} 10 | terraform init 11 | terraform validate 12 | done 13 | -------------------------------------------------------------------------------- /templates/data-sources/aws_privatelink_endpoint.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/azure_privatelink_endpoint.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/deployment.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/deployment_templates.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/deployments.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/gcp_private_service_connect_endpoint.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/stack.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/data-sources/traffic_filter.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | -------------------------------------------------------------------------------- /templates/resources/deployment_elasticsearch_keystore.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | ### Basic 14 | 15 | {{ tffile "examples/resources/ec_deployment_elasticsearch_keystore/basic/resource.tf" }} 16 | 17 | ### Adding credentials to use GCS as a snapshot repository 18 | 19 | {{ tffile "examples/resources/ec_deployment_elasticsearch_keystore/gcs-snapshots/resource.tf" }} 20 | 21 | {{ .SchemaMarkdown | trimspace }} 22 | 23 | ## Import 24 | 25 | This resource cannot be imported 26 | -------------------------------------------------------------------------------- /templates/resources/deployment_extension.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | ### With extension file 14 | 15 | {{ tffile "examples/resources/ec_deployment_extension/with-file/resource.tf" }} 16 | 17 | ### With download URL 18 | 19 | {{ tffile "examples/resources/ec_deployment_extension/with-url/resource.tf" }} 20 | 21 | {{ .SchemaMarkdown | trimspace }} 22 | 23 | ## Import 24 | 25 | Extensions can be imported using the `id`, for example: 26 | 27 | {{ codefile "shell" .ImportFile }} 28 | -------------------------------------------------------------------------------- /templates/resources/deployment_traffic_filter.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | ### IP based traffic filter 14 | 15 | {{ tffile "examples/resources/ec_deployment_traffic_filter/ip/resource.tf" }} 16 | 17 | ### Azure Private Link traffic filter 18 | 19 | {{ tffile "examples/resources/ec_deployment_traffic_filter/azure/resource.tf" }} 20 | 21 | ### GCP Private Service Connect traffic filter 22 | 23 | {{ tffile "examples/resources/ec_deployment_traffic_filter/gcp/resource.tf" }} 24 | 25 | {{ .SchemaMarkdown | trimspace }} 26 | 27 | ## Import 28 | 29 | Traffic filters can be imported using the `id`, for example: 30 | 31 | {{ codefile "shell" .ImportFile }} 32 | -------------------------------------------------------------------------------- /templates/resources/deployment_traffic_filter_association.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | {{ tffile .ExampleFile }} 14 | 15 | {{ .SchemaMarkdown | trimspace }} 16 | 17 | ## Import 18 | 19 | Import is not supported on this resource 20 | -------------------------------------------------------------------------------- /templates/resources/elasticsearch_project.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | ## Technical preview 10 | 11 | This functionality is in technical preview and may be changed or removed in a future release. 12 | Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. 13 | 14 | {{ .Description }} 15 | 16 | ## Example Usage 17 | 18 | {{ tffile "examples/resources/ec_elasticsearch_project/resource.tf" }} 19 | 20 | {{ .SchemaMarkdown | trimspace }} 21 | 22 | ## Import 23 | 24 | Projects can be imported using the `id`, for example: 25 | 26 | {{ codefile "shell" .ImportFile }} 27 | -------------------------------------------------------------------------------- /templates/resources/observability_project.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | ## Technical preview 10 | 11 | This functionality is in technical preview and may be changed or removed in a future release. 12 | Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. 13 | 14 | {{ .Description }} 15 | 16 | ## Example Usage 17 | 18 | {{ tffile "examples/resources/ec_observability_project/resource.tf" }} 19 | 20 | {{ .SchemaMarkdown | trimspace }} 21 | 22 | ## Import 23 | 24 | Projects can be imported using the `id`, for example: 25 | 26 | {{ codefile "shell" .ImportFile }} 27 | -------------------------------------------------------------------------------- /templates/resources/organization.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | ### Import 14 | 15 | To import an organization into terraform, first define your organization configuration in your terraform file. For example: 16 | ```terraform 17 | resource "ec_organization" "myorg" { 18 | } 19 | ``` 20 | 21 | Then import the organization using your organization-id (The organization id can be found on [the organization page](https://cloud.elastic.co/account/members)) 22 | ```bash 23 | terraform import ec_organization.myorg 24 | ``` 25 | 26 | Now you can run `terraform plan` to see if there are any diffs between your config and how your organization is currently configured. 27 | 28 | ### Basic 29 | 30 | {{ tffile "examples/resources/ec_organization/basic.tf" }} 31 | 32 | ### Use variables to give the same roles to multiple users 33 | 34 | {{ tffile "examples/resources/ec_organization/locals.tf" }} 35 | 36 | {{ .SchemaMarkdown | trimspace }} -------------------------------------------------------------------------------- /templates/resources/security_project.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | ## Technical preview 10 | 11 | This functionality is in technical preview and may be changed or removed in a future release. 12 | Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. 13 | 14 | {{ .Description }} 15 | 16 | ## Example Usage 17 | 18 | {{ tffile "examples/resources/ec_security_project/resource.tf" }} 19 | 20 | {{ .SchemaMarkdown | trimspace }} 21 | 22 | ## Import 23 | 24 | Projects can be imported using the `id`, for example: 25 | 26 | {{ codefile "shell" .ImportFile }} 27 | -------------------------------------------------------------------------------- /templates/resources/snapshot_repository.md.tmpl: -------------------------------------------------------------------------------- 1 | --- 2 | page_title: "Elastic Cloud: {{ .Name }} {{ .Type }}" 3 | description: |- 4 | {{ .Description }} 5 | --- 6 | 7 | # {{ .Type }}: {{ .Name }} 8 | 9 | {{ .Description }} 10 | 11 | ## Example Usage 12 | 13 | ### S3 style 14 | 15 | {{ tffile "examples/resources/ec_snapshot_repository/resource-s3.tf" }} 16 | 17 | ### Azure 18 | 19 | {{ tffile "examples/resources/ec_snapshot_repository/resource-azure.tf" }} 20 | 21 | ### GCS 22 | 23 | {{ tffile "examples/resources/ec_snapshot_repository/resource-gcs.tf" }} 24 | 25 | {{ .SchemaMarkdown | trimspace }} 26 | 27 | ## Import 28 | 29 | You can import snapshot repositories using the `name`, for example: 30 | 31 | {{ codefile "shell" .ImportFile }} 32 | -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V. under one or more contributor 2 | // license agreements. See the NOTICE file distributed with 3 | // this work for additional information regarding copyright 4 | // ownership. Elasticsearch B.V. licenses this file to you under 5 | // the Apache License, Version 2.0 (the "License"); you may 6 | // not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, 12 | // software distributed under the License is distributed on an 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | // KIND, either express or implied. See the License for the 15 | // specific language governing permissions and limitations 16 | // under the License. 17 | 18 | //go:build tools 19 | // +build tools 20 | 21 | package main 22 | 23 | import ( 24 | _ "github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen" 25 | _ "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework" 26 | _ "github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi" 27 | ) 28 | --------------------------------------------------------------------------------