diff --git a/examples/typescript/aws-import/main.ts b/examples/typescript/aws-import/main.ts index a76a22da9c..0acd11f887 100644 --- a/examples/typescript/aws-import/main.ts +++ b/examples/typescript/aws-import/main.ts @@ -38,7 +38,7 @@ class StackWithImportAndConfigurationGeneration extends TerraformStack { }); // Step 2: Create import block - S3Bucket.importGenerateConfig(this, "bucket", bucketId); + S3Bucket.generateConfigForImport(this, "bucket", bucketId); // Step 3: Run `cdktf plan` and get the configuration to put in below // Step 4: Remove the `import` call, the resource is now imported diff --git a/packages/@cdktf/cli-core/src/lib/cdktf-stack.ts b/packages/@cdktf/cli-core/src/lib/cdktf-stack.ts index 38ea7b90b7..b555a40445 100644 --- a/packages/@cdktf/cli-core/src/lib/cdktf-stack.ts +++ b/packages/@cdktf/cli-core/src/lib/cdktf-stack.ts @@ -8,7 +8,8 @@ import { extractJsonLogIfPresent } from "./server/terraform-logs"; import { TerraformCli, OutputFilter, - findGeneratedConfigurationFile, + tryReadGeneratedConfigurationFile, + tryRemoveGeneratedConfigurationFile, } from "./models/terraform-cli"; import { ProviderConstraint } from "./dependencies/dependency-manager"; import { terraformJsonSchema, TerraformStack } from "./terraform-json"; @@ -379,7 +380,7 @@ export class CdktfStack { this.updateState({ type: "planned", stackName: this.stack.name }); // Find generated file - const configFile = await findGeneratedConfigurationFile( + const configFile = await tryReadGeneratedConfigurationFile( this.stack.workingDirectory ); if (configFile) { @@ -389,7 +390,10 @@ export class CdktfStack { configuration: configFile, }); - const convertedCode = await convertConfigurationFile(configFile); + const convertedCode = await convertConfigurationFile( + configFile, + this.stack.workingDirectory + ); this.updateState({ type: "import with configuration converted", stackName: this.stack.name, @@ -406,10 +410,15 @@ CDKTF has translated the code to the following: ${convertedCode} Please review the code and make any necessary changes before adding it to your codebase. -Make sure to only copy the code within the construct's constructor.`, +Make sure to only copy the code within the construct's constructor. + +NOTE: Your resource has not yet become managed by CDKTF. +To finish the import remove the call "generateConfigForImport", add the above code within the construct's constructor, and then append the call importFrom({resource_id_to_import_from}) to the generated code. +`, isError: false, }); } + await tryRemoveGeneratedConfigurationFile(this.stack.workingDirectory); } }); } diff --git a/packages/@cdktf/cli-core/src/lib/convert.ts b/packages/@cdktf/cli-core/src/lib/convert.ts index 0a24c53107..4ffcb5375f 100644 --- a/packages/@cdktf/cli-core/src/lib/convert.ts +++ b/packages/@cdktf/cli-core/src/lib/convert.ts @@ -13,8 +13,11 @@ import { ConstructsMakerProviderTarget, } from "@cdktf/commons"; -export async function convertConfigurationFile(configuration: string) { - const cfg = CdktfConfig.read(process.cwd()); // TODO: make this the project directory instead of cwd +export async function convertConfigurationFile( + configuration: string, + stackWorkingDirectory: string +) { + const cfg = CdktfConfig.read(stackWorkingDirectory); // TODO: make this the project directory instead of cwd const targets = cfg.terraformProviders.map((constraint) => ConstructsMakerProviderTarget.from( new TerraformProviderConstraint(constraint), diff --git a/packages/@cdktf/cli-core/src/lib/models/terraform-cli.ts b/packages/@cdktf/cli-core/src/lib/models/terraform-cli.ts index 2f5a353993..5faa3e7e34 100644 --- a/packages/@cdktf/cli-core/src/lib/models/terraform-cli.ts +++ b/packages/@cdktf/cli-core/src/lib/models/terraform-cli.ts @@ -81,6 +81,7 @@ class VariableRequiredFilter extends AbstractOutputFilter { export class TerraformCli implements Terraform { public readonly workdir: string; + static readonly generatedImportConfigFile: string = "generated_resources.tf"; private readonly onStdout: ( stateName: string, filter?: OutputFilter[] @@ -227,13 +228,15 @@ export class TerraformCli implements Terraform { const generatedConfigFile = path.join( this.workdir, - "generated_resources.tf" + TerraformCli.generatedImportConfigFile ); if (fs.existsSync(generatedConfigFile)) { fs.remove(generatedConfigFile); } if (this.hasImports) { - options.push("-generate-config-out=generated_resources.tf"); + options.push( + `-generate-config-out=${TerraformCli.generatedImportConfigFile}` + ); } if (!this.isCloudStack) { const planFile = "plan"; @@ -481,12 +484,25 @@ export class TerraformCli implements Terraform { } } -export async function findGeneratedConfigurationFile( +export async function tryReadGeneratedConfigurationFile( workingDir: string ): Promise { - const generatedConfigPath = path.join(workingDir, "generated_resources.tf"); + const generatedConfigPath = path.join( + workingDir, + TerraformCli.generatedImportConfigFile + ); if (!fs.existsSync(generatedConfigPath)) { return null; } return fs.readFileSync(generatedConfigPath, "utf-8"); } + +export async function tryRemoveGeneratedConfigurationFile(workingDir: string) { + const generatedConfigPath = path.join( + workingDir, + TerraformCli.generatedImportConfigFile + ); + if (fs.existsSync(generatedConfigPath)) { + fs.unlinkSync(generatedConfigPath); + } +} diff --git a/packages/@cdktf/provider-generator/lib/__tests__/__snapshots__/provider.test.ts.snap b/packages/@cdktf/provider-generator/lib/__tests__/__snapshots__/provider.test.ts.snap index 37f352f773..8f35940954 100644 --- a/packages/@cdktf/provider-generator/lib/__tests__/__snapshots__/provider.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/__tests__/__snapshots__/provider.test.ts.snap @@ -45,6 +45,20 @@ export class ApiKey extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_api_key"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_api_key to import to, as it appears in generated config + * @param importFormId The id of the datadog_api_key in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_api_key to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_api_key", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -164,6 +178,20 @@ export class ApplicationKey extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_application_key"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_application_key to import to, as it appears in generated config + * @param importFormId The id of the datadog_application_key in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_application_key to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_application_key", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -295,6 +323,20 @@ export class AuthnMapping extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_authn_mapping"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_authn_mapping to import to, as it appears in generated config + * @param importFormId The id of the datadog_authn_mapping in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_authn_mapping to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_authn_mapping", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -1030,6 +1072,20 @@ export class ChildOrganization extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_child_organization"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_child_organization to import to, as it appears in generated config + * @param importFormId The id of the datadog_child_organization in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_child_organization to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_child_organization", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -1196,6 +1252,20 @@ export class CloudWorkloadSecurityAgentRule extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_cloud_workload_security_agent_rule"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_cloud_workload_security_agent_rule to import to, as it appears in generated config + * @param importFormId The id of the datadog_cloud_workload_security_agent_rule in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_cloud_workload_security_agent_rule to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_cloud_workload_security_agent_rule", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -1373,6 +1443,20 @@ export class DashboardJson extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_dashboard_json"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_dashboard_json to import to, as it appears in generated config + * @param importFormId The id of the datadog_dashboard_json in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_dashboard_json to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_dashboard_json", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -1656,6 +1740,20 @@ export class DashboardList extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_dashboard_list"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_dashboard_list to import to, as it appears in generated config + * @param importFormId The id of the datadog_dashboard_list in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_dashboard_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_dashboard_list", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -172993,6 +173091,20 @@ export class Dashboard extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_dashboard"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_dashboard to import to, as it appears in generated config + * @param importFormId The id of the datadog_dashboard in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_dashboard to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_dashboard", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -173309,6 +173421,20 @@ export class DataDatadogApiKey extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_api_key"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_api_key to import to, as it appears in generated config + * @param importFormId The id of the datadog_api_key in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_api_key to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_api_key", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -173433,6 +173559,20 @@ export class DataDatadogApplicationKey extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_application_key"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_application_key to import to, as it appears in generated config + * @param importFormId The id of the datadog_application_key in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_application_key to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_application_key", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -173633,6 +173773,20 @@ export class DataDatadogCloudWorkloadSecurityAgentRules extends cdktf.TerraformD // ================= public static readonly tfResourceType = "datadog_cloud_workload_security_agent_rules"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_cloud_workload_security_agent_rules to import to, as it appears in generated config + * @param importFormId The id of the datadog_cloud_workload_security_agent_rules in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_cloud_workload_security_agent_rules to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_cloud_workload_security_agent_rules", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -173738,6 +173892,20 @@ export class DataDatadogDashboardList extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_dashboard_list"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_dashboard_list to import to, as it appears in generated config + * @param importFormId The id of the datadog_dashboard_list in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_dashboard_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_dashboard_list", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -173852,6 +174020,20 @@ export class DataDatadogDashboard extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_dashboard"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_dashboard to import to, as it appears in generated config + * @param importFormId The id of the datadog_dashboard in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_dashboard to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_dashboard", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -173970,6 +174152,20 @@ export class DataDatadogIpRanges extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_ip_ranges"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_ip_ranges to import to, as it appears in generated config + * @param importFormId The id of the datadog_ip_ranges in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_ip_ranges to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_ip_ranges", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -174145,6 +174341,20 @@ export class DataDatadogLogsIndexesOrder extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_logs_indexes_order"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_indexes_order to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_indexes_order in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_indexes_order to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_indexes_order", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -174537,6 +174747,20 @@ export class DataDatadogLogsIndexes extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_logs_indexes"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_indexes to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_indexes in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_indexes to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_indexes", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -174812,6 +175036,20 @@ export class DataDatadogMonitor extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_monitor"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_monitor to import to, as it appears in generated config + * @param importFormId The id of the datadog_monitor in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_monitor to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_monitor", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -175173,6 +175411,20 @@ export class DataDatadogMonitors extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_monitors"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_monitors to import to, as it appears in generated config + * @param importFormId The id of the datadog_monitors in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_monitors to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_monitors", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -175326,6 +175578,20 @@ export class DataDatadogPermissions extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_permissions"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_permissions to import to, as it appears in generated config + * @param importFormId The id of the datadog_permissions in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_permissions to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_permissions", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -175431,6 +175697,20 @@ export class DataDatadogRole extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_role"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_role to import to, as it appears in generated config + * @param importFormId The id of the datadog_role in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_role to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_role", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -175629,6 +175909,20 @@ export class DataDatadogRoles extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_roles"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_roles to import to, as it appears in generated config + * @param importFormId The id of the datadog_roles in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_roles to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_roles", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -175905,6 +176199,20 @@ export class DataDatadogSecurityMonitoringFilters extends cdktf.TerraformDataSou // ================= public static readonly tfResourceType = "datadog_security_monitoring_filters"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_security_monitoring_filters to import to, as it appears in generated config + * @param importFormId The id of the datadog_security_monitoring_filters in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_security_monitoring_filters to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_security_monitoring_filters", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -176682,6 +176990,20 @@ export class DataDatadogSecurityMonitoringRules extends cdktf.TerraformDataSourc // ================= public static readonly tfResourceType = "datadog_security_monitoring_rules"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_security_monitoring_rules to import to, as it appears in generated config + * @param importFormId The id of the datadog_security_monitoring_rules in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_security_monitoring_rules to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_security_monitoring_rules", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -176878,6 +177200,20 @@ export class DataDatadogServiceLevelObjective extends cdktf.TerraformDataSource // ================= public static readonly tfResourceType = "datadog_service_level_objective"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_service_level_objective to import to, as it appears in generated config + * @param importFormId The id of the datadog_service_level_objective in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_service_level_objective to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_service_level_objective", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -177133,6 +177469,20 @@ export class DataDatadogServiceLevelObjectives extends cdktf.TerraformDataSource // ================= public static readonly tfResourceType = "datadog_service_level_objectives"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_service_level_objectives to import to, as it appears in generated config + * @param importFormId The id of the datadog_service_level_objectives in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_service_level_objectives to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_service_level_objectives", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -177310,6 +177660,20 @@ export class DataDatadogSyntheticsGlobalVariable extends cdktf.TerraformDataSour // ================= public static readonly tfResourceType = "datadog_synthetics_global_variable"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_synthetics_global_variable to import to, as it appears in generated config + * @param importFormId The id of the datadog_synthetics_global_variable in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_synthetics_global_variable to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_synthetics_global_variable", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -177423,6 +177787,20 @@ export class DataDatadogSyntheticsLocations extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_synthetics_locations"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_synthetics_locations to import to, as it appears in generated config + * @param importFormId The id of the datadog_synthetics_locations in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_synthetics_locations to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_synthetics_locations", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -177528,6 +177906,20 @@ export class DataDatadogSyntheticsTest extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_synthetics_test"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_synthetics_test to import to, as it appears in generated config + * @param importFormId The id of the datadog_synthetics_test in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_synthetics_test to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_synthetics_test", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -177657,6 +178049,20 @@ export class DataDatadogUser extends cdktf.TerraformDataSource { // ================= public static readonly tfResourceType = "datadog_user"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_user to import to, as it appears in generated config + * @param importFormId The id of the datadog_user in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_user to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_user", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -178050,6 +178456,20 @@ export class Downtime extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_downtime"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_downtime to import to, as it appears in generated config + * @param importFormId The id of the datadog_downtime in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_downtime to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_downtime", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -178433,6 +178853,20 @@ export class IntegrationAwsLambdaArn extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_aws_lambda_arn"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_aws_lambda_arn to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_aws_lambda_arn in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_aws_lambda_arn to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_aws_lambda_arn", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -178568,6 +179002,20 @@ export class IntegrationAwsLogCollection extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_aws_log_collection"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_aws_log_collection to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_aws_log_collection in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_aws_log_collection to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_aws_log_collection", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -178709,6 +179157,20 @@ export class IntegrationAwsTagFilter extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_aws_tag_filter"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_aws_tag_filter to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_aws_tag_filter in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_aws_tag_filter to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_aws_tag_filter", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -178913,6 +179375,20 @@ export class IntegrationAws extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_aws"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_aws to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_aws in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_aws to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_aws", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -179239,6 +179715,20 @@ export class IntegrationAzure extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_azure"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_azure to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_azure in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_azure to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_azure", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -179455,6 +179945,20 @@ export class IntegrationGcp extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_gcp"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_gcp to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_gcp in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_gcp to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_gcp", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -179671,6 +180175,20 @@ export class IntegrationPagerdutyServiceObject extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_pagerduty_service_object"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_pagerduty_service_object to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_pagerduty_service_object in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_pagerduty_service_object to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_pagerduty_service_object", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -179812,6 +180330,20 @@ export class IntegrationPagerduty extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_pagerduty"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_pagerduty to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_pagerduty in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_pagerduty to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_pagerduty", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -180128,6 +180660,20 @@ export class IntegrationSlackChannel extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_integration_slack_channel"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_integration_slack_channel to import to, as it appears in generated config + * @param importFormId The id of the datadog_integration_slack_channel in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_integration_slack_channel to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_integration_slack_channel", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -180340,6 +180886,20 @@ export class LogsArchiveOrder extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_archive_order"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_archive_order to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_archive_order in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_archive_order to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_archive_order", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -180954,6 +181514,20 @@ export class LogsArchive extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_archive"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_archive to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_archive in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_archive to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_archive", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -187632,6 +188206,20 @@ export class LogsCustomPipeline extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_custom_pipeline"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_custom_pipeline to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_custom_pipeline in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_custom_pipeline to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_custom_pipeline", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -187803,6 +188391,20 @@ export class LogsIndexOrder extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_index_order"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_index_order to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_index_order in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_index_order to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_index_order", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -188311,6 +188913,20 @@ export class LogsIndex extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_index"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_index to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_index in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_index to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_index", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -188512,6 +189128,20 @@ export class LogsIntegrationPipeline extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_integration_pipeline"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_integration_pipeline to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_integration_pipeline in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_integration_pipeline to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_integration_pipeline", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -188926,6 +189556,20 @@ export class LogsMetric extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_metric"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_metric to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_metric in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_metric to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_metric", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -189094,6 +189738,20 @@ export class LogsPipelineOrder extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_logs_pipeline_order"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_logs_pipeline_order to import to, as it appears in generated config + * @param importFormId The id of the datadog_logs_pipeline_order in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_logs_pipeline_order to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_logs_pipeline_order", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -189259,6 +189917,20 @@ export class MetricMetadata extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_metric_metadata"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_metric_metadata to import to, as it appears in generated config + * @param importFormId The id of the datadog_metric_metadata in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_metric_metadata to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_metric_metadata", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -189627,6 +190299,20 @@ export class MetricTagConfiguration extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_metric_tag_configuration"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_metric_tag_configuration to import to, as it appears in generated config + * @param importFormId The id of the datadog_metric_tag_configuration in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_metric_tag_configuration to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_metric_tag_configuration", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -189813,6 +190499,20 @@ export class MonitorJson extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_monitor_json"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_monitor_json to import to, as it appears in generated config + * @param importFormId The id of the datadog_monitor_json in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_monitor_json to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_monitor_json", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -190421,6 +191121,20 @@ export class Monitor extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_monitor"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_monitor to import to, as it appears in generated config + * @param importFormId The id of the datadog_monitor in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_monitor to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_monitor", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -191517,6 +192231,20 @@ export class OrganizationSettings extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_organization_settings"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_organization_settings to import to, as it appears in generated config + * @param importFormId The id of the datadog_organization_settings in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_organization_settings to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_organization_settings", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -191691,6 +192419,20 @@ export class DatadogProvider extends cdktf.TerraformProvider { // ================= public static readonly tfResourceType = "datadog"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog to import to, as it appears in generated config + * @param importFormId The id of the datadog in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -192002,6 +192744,20 @@ export class Role extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_role"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_role to import to, as it appears in generated config + * @param importFormId The id of the datadog_role in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_role to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_role", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -192395,6 +193151,20 @@ export class SecurityMonitoringDefaultRule extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_security_monitoring_default_rule"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_security_monitoring_default_rule to import to, as it appears in generated config + * @param importFormId The id of the datadog_security_monitoring_default_rule in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_security_monitoring_default_rule to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_security_monitoring_default_rule", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -192694,6 +193464,20 @@ export class SecurityMonitoringFilter extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_security_monitoring_filter"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_security_monitoring_filter to import to, as it appears in generated config + * @param importFormId The id of the datadog_security_monitoring_filter in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_security_monitoring_filter to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_security_monitoring_filter", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -193993,6 +194777,20 @@ export class SecurityMonitoringRule extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_security_monitoring_rule"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_security_monitoring_rule to import to, as it appears in generated config + * @param importFormId The id of the datadog_security_monitoring_rule in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_security_monitoring_rule to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_security_monitoring_rule", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -194565,6 +195363,20 @@ export class ServiceLevelObjective extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_service_level_objective"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_service_level_objective to import to, as it appears in generated config + * @param importFormId The id of the datadog_service_level_objective in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_service_level_objective to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_service_level_objective", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -194877,6 +195689,20 @@ export class SloCorrection extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_slo_correction"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_slo_correction to import to, as it appears in generated config + * @param importFormId The id of the datadog_slo_correction in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_slo_correction to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_slo_correction", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -195365,6 +196191,20 @@ export class SyntheticsGlobalVariable extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_synthetics_global_variable"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_synthetics_global_variable to import to, as it appears in generated config + * @param importFormId The id of the datadog_synthetics_global_variable in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_synthetics_global_variable to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_synthetics_global_variable", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -195687,6 +196527,20 @@ export class SyntheticsPrivateLocation extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_synthetics_private_location"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_synthetics_private_location to import to, as it appears in generated config + * @param importFormId The id of the datadog_synthetics_private_location in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_synthetics_private_location to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_synthetics_private_location", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -201846,6 +202700,20 @@ export class SyntheticsTest extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_synthetics_test"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_synthetics_test to import to, as it appears in generated config + * @param importFormId The id of the datadog_synthetics_test in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_synthetics_test to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_synthetics_test", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -202340,6 +203208,20 @@ export class User extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_user"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_user to import to, as it appears in generated config + * @param importFormId The id of the datadog_user in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_user to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_user", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -202548,6 +203430,20 @@ export class WebhookCustomVariable extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_webhook_custom_variable"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_webhook_custom_variable to import to, as it appears in generated config + * @param importFormId The id of the datadog_webhook_custom_variable in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_webhook_custom_variable to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_webhook_custom_variable", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== @@ -202716,6 +203612,20 @@ export class Webhook extends cdktf.TerraformResource { // ================= public static readonly tfResourceType = "datadog_webhook"; + // ============== + // STATIC Methods + // ============== + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_webhook to import to, as it appears in generated config + * @param importFormId The id of the datadog_webhook in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_webhook to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_webhook", importId: importFromId, provider }); + } + // =========== // INITIALIZER // =========== diff --git a/packages/@cdktf/provider-generator/lib/__tests__/provider.test.ts b/packages/@cdktf/provider-generator/lib/__tests__/provider.test.ts index 2bb29cc98f..3d9da294a6 100644 --- a/packages/@cdktf/provider-generator/lib/__tests__/provider.test.ts +++ b/packages/@cdktf/provider-generator/lib/__tests__/provider.test.ts @@ -62,7 +62,7 @@ describe("Provider", () => { expect(snapshot).toMatchSnapshot(); }); }, 600_000), - it.only("has generated provider that includes static import functions", async () => { + it("has generated provider that includes static import functions", async () => { const constraint = new TerraformProviderConstraint( "DataDog/datadog@= 3.12.0" ); @@ -96,10 +96,10 @@ describe("Provider", () => { terraformResourceType = `datadog_${terraformResourceType}`; } expect(snapshot[`providers/datadog/${resource}/index.ts`]).toContain( - `public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider)` + `public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) {` ); expect(snapshot[`providers/datadog/${resource}/index.ts`]).toContain( - `return new cdktf.ImportableResource(scope, name, { terraformResourceType: "${terraformResourceType}", importId: id, provider });` + `return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "${terraformResourceType}", importId: importFromId, provider });` ); }); }); diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/complex-computed-types.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/complex-computed-types.test.ts.snap index 36fe3a1290..e59b04edd5 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/complex-computed-types.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/complex-computed-types.test.ts.snap @@ -214,8 +214,15 @@ export class AcmCertificate extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_acm_certificate", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_acm_certificate to import to, as it appears in generated config + * @param importFormId The id of the aws_acm_certificate in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_acm_certificate to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_acm_certificate", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/description-escaping.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/description-escaping.test.ts.snap index 81524d50ce..283c9e723f 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/description-escaping.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/description-escaping.test.ts.snap @@ -37,8 +37,15 @@ export class DescriptionEscaping extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "description_escaping", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the description_escaping to import to, as it appears in generated config + * @param importFormId The id of the description_escaping in the cloud provider to generate config of + * @param provider? Instance of the provider where description_escaping to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "description_escaping", importId: importFromId, provider }); } // =========== @@ -132,8 +139,15 @@ export class CodeBlocks extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "code_blocks", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the code_blocks to import to, as it appears in generated config + * @param importFormId The id of the code_blocks in the cloud provider to generate config of + * @param provider? Instance of the provider where code_blocks to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "code_blocks", importId: importFromId, provider }); } // =========== @@ -225,8 +239,15 @@ export class CodeBlocks extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "code_blocks", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the code_blocks to import to, as it appears in generated config + * @param importFormId The id of the code_blocks in the cloud provider to generate config of + * @param provider? Instance of the provider where code_blocks to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "code_blocks", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/export-sharding.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/export-sharding.test.ts.snap index c21831228b..2e82bed3a1 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/export-sharding.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/export-sharding.test.ts.snap @@ -110,8 +110,15 @@ export class Dashboard extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "datadog_dashboard", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the datadog_dashboard to import to, as it appears in generated config + * @param importFormId The id of the datadog_dashboard in the cloud provider to generate config of + * @param provider? Instance of the provider where datadog_dashboard to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "datadog_dashboard", importId: importFromId, provider }); } // =========== @@ -146871,8 +146878,15 @@ export class Wafv2WebAcl extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_wafv2_web_acl", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_wafv2_web_acl to import to, as it appears in generated config + * @param importFormId The id of the aws_wafv2_web_acl in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_wafv2_web_acl to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_wafv2_web_acl", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/nested-types.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/nested-types.test.ts.snap index 12151e7fc7..bbfe0cfd13 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/nested-types.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/nested-types.test.ts.snap @@ -303,8 +303,15 @@ export class NestedTypesResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "nested_types_resource", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the nested_types_resource to import to, as it appears in generated config + * @param importFormId The id of the nested_types_resource in the cloud provider to generate config of + * @param provider? Instance of the provider where nested_types_resource to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "nested_types_resource", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/provider.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/provider.test.ts.snap index d61157b064..242f8d6b01 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/provider.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/provider.test.ts.snap @@ -1173,8 +1173,15 @@ export class AwsProvider extends cdktf.TerraformProvider { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws to import to, as it appears in generated config + * @param importFormId The id of the aws in the cloud provider to generate config of + * @param provider? Instance of the provider where aws to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws", importId: importFromId, provider }); } // =========== @@ -1697,8 +1704,15 @@ export class ElasticstackProvider extends cdktf.TerraformProvider { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "elasticstack", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the elasticstack to import to, as it appears in generated config + * @param importFormId The id of the elasticstack in the cloud provider to generate config of + * @param provider? Instance of the provider where elasticstack to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "elasticstack", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/resource-types.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/resource-types.test.ts.snap index b8d4a540d2..3de33b1606 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/resource-types.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/resource-types.test.ts.snap @@ -4023,8 +4023,15 @@ export class CloudfrontDistribution extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_cloudfront_distribution", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_cloudfront_distribution to import to, as it appears in generated config + * @param importFormId The id of the aws_cloudfront_distribution in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_cloudfront_distribution to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_cloudfront_distribution", importId: importFromId, provider }); } // =========== @@ -4515,8 +4522,15 @@ export class FmsAdminAccount extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_fms_admin_account", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_fms_admin_account to import to, as it appears in generated config + * @param importFormId The id of the aws_fms_admin_account in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_fms_admin_account to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_fms_admin_account", importId: importFromId, provider }); } // =========== @@ -7536,8 +7550,15 @@ export class S3Bucket extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_s3_bucket", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_s3_bucket to import to, as it appears in generated config + * @param importFormId The id of the aws_s3_bucket in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_s3_bucket to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_s3_bucket", importId: importFromId, provider }); } // =========== @@ -8805,8 +8826,15 @@ export class SecurityGroup extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_security_group", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_security_group to import to, as it appears in generated config + * @param importFormId The id of the aws_security_group in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_security_group to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_security_group", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/skipped-attributes.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/skipped-attributes.test.ts.snap index c413260aee..d6b6196753 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/skipped-attributes.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/skipped-attributes.test.ts.snap @@ -691,8 +691,15 @@ export class QuicksightTemplate extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_quicksight_template", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_quicksight_template to import to, as it appears in generated config + * @param importFormId The id of the aws_quicksight_template in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_quicksight_template to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_quicksight_template", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/types.test.ts.snap b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/types.test.ts.snap index d5cce8d29e..f091d6cdd9 100644 --- a/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/types.test.ts.snap +++ b/packages/@cdktf/provider-generator/lib/get/__tests__/generator/__snapshots__/types.test.ts.snap @@ -33,8 +33,15 @@ export class BooleanList extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_boolean_list", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_boolean_list to import to, as it appears in generated config + * @param importFormId The id of the aws_boolean_list in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_boolean_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_boolean_list", importId: importFromId, provider }); } // =========== @@ -152,8 +159,15 @@ export class BooleanMap extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_boolean_map", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_boolean_map to import to, as it appears in generated config + * @param importFormId The id of the aws_boolean_map in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_boolean_map to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_boolean_map", importId: importFromId, provider }); } // =========== @@ -370,8 +384,15 @@ export class ComputedComplex extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_computed_complex", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_computed_complex to import to, as it appears in generated config + * @param importFormId The id of the aws_computed_complex in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_computed_complex to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_computed_complex", importId: importFromId, provider }); } // =========== @@ -582,8 +603,15 @@ export class ComputedComplexNested extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_computed_complex_nested", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_computed_complex_nested to import to, as it appears in generated config + * @param importFormId The id of the aws_computed_complex_nested in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_computed_complex_nested to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_computed_complex_nested", importId: importFromId, provider }); } // =========== @@ -840,8 +868,15 @@ export class BlockTypeNestedComputedList extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_block_type_nested_computed_list", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_block_type_nested_computed_list to import to, as it appears in generated config + * @param importFormId The id of the aws_block_type_nested_computed_list in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_block_type_nested_computed_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_block_type_nested_computed_list", importId: importFromId, provider }); } // =========== @@ -1247,8 +1282,15 @@ export class ComputedOptionalComplex extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_computed_optional_complex", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_computed_optional_complex to import to, as it appears in generated config + * @param importFormId The id of the aws_computed_optional_complex in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_computed_optional_complex to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_computed_optional_complex", importId: importFromId, provider }); } // =========== @@ -1534,8 +1576,15 @@ export class DeeplyNestedBlockTypes extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_deeply_nested_block_types", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_deeply_nested_block_types to import to, as it appears in generated config + * @param importFormId The id of the aws_deeply_nested_block_types in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_deeply_nested_block_types to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_deeply_nested_block_types", importId: importFromId, provider }); } // =========== @@ -1631,8 +1680,15 @@ export class IgnoredAttributes extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_ignored_attributes", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_ignored_attributes to import to, as it appears in generated config + * @param importFormId The id of the aws_ignored_attributes in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_ignored_attributes to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_ignored_attributes", importId: importFromId, provider }); } // =========== @@ -1746,8 +1802,15 @@ export class IncompatibleAttributeNames extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_incompatible_attribute_names", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_incompatible_attribute_names to import to, as it appears in generated config + * @param importFormId The id of the aws_incompatible_attribute_names in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_incompatible_attribute_names to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_incompatible_attribute_names", importId: importFromId, provider }); } // =========== @@ -1900,8 +1963,15 @@ export class FunctionResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_function", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_function to import to, as it appears in generated config + * @param importFormId The id of the test_function in the cloud provider to generate config of + * @param provider? Instance of the provider where test_function to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_function", importId: importFromId, provider }); } // =========== @@ -2018,8 +2088,15 @@ export class LicenseResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_license", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_license to import to, as it appears in generated config + * @param importFormId The id of the test_license in the cloud provider to generate config of + * @param provider? Instance of the provider where test_license to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_license", importId: importFromId, provider }); } // =========== @@ -2112,8 +2189,15 @@ export class ObjectResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_object", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_object to import to, as it appears in generated config + * @param importFormId The id of the test_object in the cloud provider to generate config of + * @param provider? Instance of the provider where test_object to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_object", importId: importFromId, provider }); } // =========== @@ -2206,8 +2290,15 @@ export class ProviderResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_provider", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_provider to import to, as it appears in generated config + * @param importFormId The id of the test_provider in the cloud provider to generate config of + * @param provider? Instance of the provider where test_provider to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_provider", importId: importFromId, provider }); } // =========== @@ -2300,8 +2391,15 @@ export class StaticResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_static", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_static to import to, as it appears in generated config + * @param importFormId The id of the test_static in the cloud provider to generate config of + * @param provider? Instance of the provider where test_static to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_static", importId: importFromId, provider }); } // =========== @@ -2394,8 +2492,15 @@ export class StringResource extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_string", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_string to import to, as it appears in generated config + * @param importFormId The id of the test_string in the cloud provider to generate config of + * @param provider? Instance of the provider where test_string to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_string", importId: importFromId, provider }); } // =========== @@ -2836,8 +2941,15 @@ export class Complex extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "test_complex", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the test_complex to import to, as it appears in generated config + * @param importFormId The id of the test_complex in the cloud provider to generate config of + * @param provider? Instance of the provider where test_complex to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "test_complex", importId: importFromId, provider }); } // =========== @@ -3047,8 +3159,15 @@ export class DataAirbyteSourceSchemaCatalog extends cdktf.TerraformDataSource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "airbyte_source_schema_catalog", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the airbyte_source_schema_catalog to import to, as it appears in generated config + * @param importFormId The id of the airbyte_source_schema_catalog in the cloud provider to generate config of + * @param provider? Instance of the provider where airbyte_source_schema_catalog to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "airbyte_source_schema_catalog", importId: importFromId, provider }); } // =========== @@ -3149,8 +3268,15 @@ export class ListOfStringMap extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_list_of_string_map", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_list_of_string_map to import to, as it appears in generated config + * @param importFormId The id of the aws_list_of_string_map in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_list_of_string_map to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_list_of_string_map", importId: importFromId, provider }); } // =========== @@ -3251,8 +3377,15 @@ export class MapOfStringList extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_map_of_string_list", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_map_of_string_list to import to, as it appears in generated config + * @param importFormId The id of the aws_map_of_string_list in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_map_of_string_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_map_of_string_list", importId: importFromId, provider }); } // =========== @@ -3355,8 +3488,15 @@ export class NumberList extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_number_list", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_number_list to import to, as it appears in generated config + * @param importFormId The id of the aws_number_list in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_number_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_number_list", importId: importFromId, provider }); } // =========== @@ -3468,8 +3608,15 @@ export class NumberMap extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_number_map", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_number_map to import to, as it appears in generated config + * @param importFormId The id of the aws_number_map in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_number_map to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_number_map", importId: importFromId, provider }); } // =========== @@ -3594,8 +3741,15 @@ export class PrimitiveBoolean extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_primitive_boolean", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_primitive_boolean to import to, as it appears in generated config + * @param importFormId The id of the aws_primitive_boolean in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_primitive_boolean to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_primitive_boolean", importId: importFromId, provider }); } // =========== @@ -3734,8 +3888,15 @@ export class PrimitiveDynamic extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_primitive_dynamic", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_primitive_dynamic to import to, as it appears in generated config + * @param importFormId The id of the aws_primitive_dynamic in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_primitive_dynamic to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_primitive_dynamic", importId: importFromId, provider }); } // =========== @@ -3875,8 +4036,15 @@ export class PrimitiveNumber extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_primitive_number", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_primitive_number to import to, as it appears in generated config + * @param importFormId The id of the aws_primitive_number in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_primitive_number to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_primitive_number", importId: importFromId, provider }); } // =========== @@ -4015,8 +4183,15 @@ export class PrimitiveString extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_primitive_string", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_primitive_string to import to, as it appears in generated config + * @param importFormId The id of the aws_primitive_string in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_primitive_string to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_primitive_string", importId: importFromId, provider }); } // =========== @@ -4159,8 +4334,15 @@ export class NameConflict extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_name_conflict", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_name_conflict to import to, as it appears in generated config + * @param importFormId The id of the aws_name_conflict in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_name_conflict to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_name_conflict", importId: importFromId, provider }); } // =========== @@ -4509,8 +4691,15 @@ export class BlockTypeSetList extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_block_type_set_list", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_block_type_set_list to import to, as it appears in generated config + * @param importFormId The id of the aws_block_type_set_list in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_block_type_set_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_block_type_set_list", importId: importFromId, provider }); } // =========== @@ -4698,8 +4887,15 @@ export class SingleBlockType extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_single_block_type", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_single_block_type to import to, as it appears in generated config + * @param importFormId The id of the aws_single_block_type in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_single_block_type to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_single_block_type", importId: importFromId, provider }); } // =========== @@ -4800,8 +4996,15 @@ export class StringList extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_string_list", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_string_list to import to, as it appears in generated config + * @param importFormId The id of the aws_string_list in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_string_list to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_string_list", importId: importFromId, provider }); } // =========== @@ -4940,8 +5143,15 @@ export class StringMap extends cdktf.TerraformResource { // ============== // STATIC Methods // ============== - public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "aws_string_map", importId: id, provider }); + /** + * For generation of configuration for import, run "cdktf plan " + * @param scope The scope in which to define this construct + * @param importToId The id of the aws_string_map to import to, as it appears in generated config + * @param importFormId The id of the aws_string_map in the cloud provider to generate config of + * @param provider? Instance of the provider where aws_string_map to import is found + */ + public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "aws_string_map", importId: importFromId, provider }); } // =========== diff --git a/packages/@cdktf/provider-generator/lib/get/generator/emitter/resource-emitter.ts b/packages/@cdktf/provider-generator/lib/get/generator/emitter/resource-emitter.ts index c61f3fb4aa..258e0dda4d 100644 --- a/packages/@cdktf/provider-generator/lib/get/generator/emitter/resource-emitter.ts +++ b/packages/@cdktf/provider-generator/lib/get/generator/emitter/resource-emitter.ts @@ -56,9 +56,24 @@ export class ResourceEmitter { } private emitStaticMethods(resource: ResourceModel) { + const comment = sanitizedComment(this.code); + comment.line( + `For generation of configuration for import, run "cdktf plan "` + ); + comment.line(`@param scope The scope in which to define this construct`); + comment.line( + `@param importToId The id of the ${resource.terraformResourceType} to import to, as it appears in generated config` + ); + comment.line( + `@param importFormId The id of the ${resource.terraformResourceType} in the cloud provider to generate config of` + ); + comment.line( + `@param provider? Instance of the provider where ${resource.terraformResourceType} to import is found` + ); + comment.end(); this.code.line( - `public static importGenerateConfig(scope: Construct, name: string, id: string, provider?: cdktf.TerraformProvider) { - return new cdktf.ImportableResource(scope, name, { terraformResourceType: "${resource.terraformResourceType}", importId: id, provider }); + `public static generateConfigForImport(scope: Construct, importToId: string, importFromId: string, provider?: cdktf.TerraformProvider) { + return new cdktf.ImportableResource(scope, importToId, { terraformResourceType: "${resource.terraformResourceType}", importId: importFromId, provider }); }` ); } diff --git a/packages/@cdktf/provider-generator/lib/get/generator/models/attribute-model.ts b/packages/@cdktf/provider-generator/lib/get/generator/models/attribute-model.ts index 94c49e8360..009927150e 100644 --- a/packages/@cdktf/provider-generator/lib/get/generator/models/attribute-model.ts +++ b/packages/@cdktf/provider-generator/lib/get/generator/models/attribute-model.ts @@ -48,7 +48,7 @@ export function escapeAttributeName(name: string) { // `tfResourceType` is already used by resources to distinguish between different resource types if (name === "tfResourceType") return `${name}Attribute`; // `importFrom` has potential for common name collision with providers - if (name === "importFrom") return `${name}Provider`; + if (name === "importFrom") return `${name}Attribute`; return name; } diff --git a/packages/cdktf/lib/importable-resource.ts b/packages/cdktf/lib/importable-resource.ts index 41ff99323a..e350b63b7d 100644 --- a/packages/cdktf/lib/importable-resource.ts +++ b/packages/cdktf/lib/importable-resource.ts @@ -32,9 +32,6 @@ export class ImportableResource extends TerraformElement { ); } - /** - * Adds this resource to the terraform JSON output. - */ public toTerraform(): any { const expectedResourceAddress = `${this.config.terraformResourceType}.${this.friendlyUniqueId}`; return { diff --git a/packages/cdktf/lib/terraform-resource.ts b/packages/cdktf/lib/terraform-resource.ts index bdde1de498..e81b01b414 100644 --- a/packages/cdktf/lib/terraform-resource.ts +++ b/packages/cdktf/lib/terraform-resource.ts @@ -96,7 +96,7 @@ export class TerraformResource public provisioners?: Array< FileProvisioner | LocalExecProvisioner | RemoteExecProvisioner >; - public imported?: TerraformResourceImport; + private _imported?: TerraformResourceImport; constructor(scope: Construct, id: string, config: TerraformResourceConfig) { super(scope, id, config.terraformResourceType); @@ -210,11 +210,11 @@ export class TerraformResource }; return { - import: this.imported + import: this._imported ? [ { - provider: this.imported.provider?.fqn, - id: this.imported.id, + provider: this._imported.provider?.fqn, + id: this._imported.id, to: `${this.terraformResourceType}.${this.friendlyUniqueId}`, }, ] @@ -234,7 +234,7 @@ export class TerraformResource [this.terraformResourceType]: Object.keys(this.rawOverrides), } : undefined, - imports: this.imported + imports: this._imported ? { [this.terraformResourceType]: [this.friendlyUniqueId], } @@ -252,7 +252,7 @@ export class TerraformResource } public importFrom(id: string, provider?: TerraformProvider) { - this.imported = { id, provider }; + this._imported = { id, provider }; this.node.addValidation( new ValidateTerraformVersion( ">=1.5", @@ -261,6 +261,6 @@ export class TerraformResource ); } public resetImport() { - this.imported = undefined; + this._imported = undefined; } } diff --git a/packages/cdktf/test/resource.test.ts b/packages/cdktf/test/resource.test.ts index 4b5bb9dc2f..38d12c134d 100644 --- a/packages/cdktf/test/resource.test.ts +++ b/packages/cdktf/test/resource.test.ts @@ -341,6 +341,5 @@ test("includes import block when import is present, provider given", () => { new TestResource(stack, "test", { name: "foo", }).importFrom("testId", provider); - console.log("stack with provider", Testing.synth(stack)); expect(Testing.synth(stack)).toMatchSnapshot(); }); diff --git a/website/docs/cdktf/concepts/resources.mdx b/website/docs/cdktf/concepts/resources.mdx index e159e4c40b..d8185a4b47 100644 --- a/website/docs/cdktf/concepts/resources.mdx +++ b/website/docs/cdktf/concepts/resources.mdx @@ -383,18 +383,19 @@ To add one configure the `lifecycle` key on your resource with an object contain ## Importing Resources -If you have existing resources that you want to manage with CDKTF, you can import them into your CDKTF application. The best way to do this is using the [`import` block feature](/terraform/language/import) of Terraform >= 1.5. You can do this in CDKTF either with a specified configuration or without, which will trigger the configuration generation. +If you have existing resources that you want to manage with CDKTF, you can import them into your CDKTF application. The best way to do this is using the [`import` block feature](/terraform/language/import) of Terraform >= 1.5. You can do this in CDKTF either with a specified configuration or without. -### Importing with Configuration +### How To Import -To import a resource with configuration, you write your resource configuration as you would normally. Then you call the `importFrom` method on the resulting resource object. This method takes the resource ID as the first argument and the provider as an optional second. The provider is only required if you have multiple providers of the same type in your configuration. +To import a resource, first instantiate an instance of the resource type you wish to import– in our case we'll be using a S3Bucket. No configuration is expilictly needed. You then call the `importFrom` method on the resource object. This method takes the ID of the resource to be imported as the first argument and the provider as an optional second. The provider is only required if you have multiple providers of the same type in your configuration. ```typescript new S3Bucket(this, "bucket", {}).importFrom(bucketId); ``` -When running plan / apply you will get the information that one resource is going to be imported. Once you ran apply you can remove the `importFrom` call and the resource will be managed by CDKTF. -The output might look like this: +When running plan / apply you will get the information that your resource is going to be imported. Once you have ran apply, you can remove the `importFrom` call and the resource will become managed by CDKTF. + +Your output might look as follows: ``` ts-import Initializing the backend... @@ -471,16 +472,17 @@ ts-import # aws_s3_bucket.bucket (bucket) will be updated in-place terraform apply "plan" ``` -### Importing without Configuration +### Generate Configuration For Import -If you want to import a resource without specifying the configuration you can use the instance method `import` on the class of the resource you want to import. This method takes the scope as the first argument, the construct name within the CDKTF program as the second, resource ID as the third argument and the provider as an optional fourth. The provider is only required if you have multiple providers of the same type in your configuration. +If you want to specify the configuration of your imported resource you can use the static method `generateConfigForImport` on the class of the resource you want to import. This method takes the scope as the first argument, the resource ID of the resource to import to (as will be given in the generated config returned), the resource ID of the resource to be imported, and the provider as an optional fourth. The provider is only required if you have multiple providers of the same type in your configuration. ```typescript -S3Bucket.import(this, "bucket", bucketId); +S3Bucket.generateConfigForImport(this, "bucket", bucketId); ``` -When running plan / apply you will get the information that one resource is going to be imported. Once you ran plan / apply, CDKTF CLI will return the CDKTF construct. You can use this in your CDKTF application after the the apply and therefore the import is done and replace the `S3Bucket.import` call. -The output might look like this: +When running `cdktf plan ` you will get the information that resource(s) is/are going to be imported, followed by the configuration of your import(s) in CDKTF specific terms. + +Your output might look as follows: ``` ts-import-with-configuration Initializing the backend... @@ -611,6 +613,8 @@ ts-import-with-configuration Import without configuration detected. Terraform h Make sure to only copy the code within the construct's constructor. ``` +Though at this point, your resource(s) has/have not been imported. To import, first add the new generated configuration to your project, then remove the initial call of `generateConfigForImport`. Finally, add the call `importFrom` as it is done in the section "How To Import" above. On apply, your resource(s) will be imported, then becoming managed by CDKTF. + ## Escape Hatch Terraform provides [meta-arguments](/terraform/language/resources/syntax#meta-arguments) to change resource behavior. For example, the `for_each` meta-argument creates multiple resource instances according to a map, or set of strings. The escape hatch allows you to use these meta-arguments to your CDKTF application and to override attributes that CDKTF cannot yet fully express.