From 0bb7c0cb2eba3b5c4654f4bf2365bd9ebc0b7f55 Mon Sep 17 00:00:00 2001 From: Aaron Torres Date: Wed, 21 Aug 2024 12:21:26 -0500 Subject: [PATCH] fixed some rds engine bugs and viz graph bugs. Added more rds imports --- .vscode/launch.json | 2 +- pkg/engine/operational_eval/vertex_path_expand.go | 14 -------------- .../iac/templates/aws/rds_instance/factory.ts | 2 +- .../iac/templates/aws/rds_subnet_group/factory.ts | 12 ++++++++++++ .../mappings/pulumi/rds_subnet_group.yaml | 6 ++++++ pkg/templates/aws/resources/rds_subnet_group.yaml | 6 ++++++ 6 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 pkg/infra/state_reader/state_template/mappings/pulumi/rds_subnet_group.yaml diff --git a/.vscode/launch.json b/.vscode/launch.json index e195fb2cd..ea088a6e8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -136,7 +136,7 @@ ], "compounds": [ { - "name": "Debug: Llotho + infra.py", + "name": "Debug: Klotho + infra.py", "configurations": [ "Debug: Klotho", "Python Debugger: Listen" diff --git a/pkg/engine/operational_eval/vertex_path_expand.go b/pkg/engine/operational_eval/vertex_path_expand.go index 8539afb94..c2351d0ef 100644 --- a/pkg/engine/operational_eval/vertex_path_expand.go +++ b/pkg/engine/operational_eval/vertex_path_expand.go @@ -47,20 +47,6 @@ func (v *pathExpandVertex) Key() Key { } func (v *pathExpandVertex) Evaluate(eval *Evaluator) error { - // if both the source and target are imported resources we can skip the evaluation since its just for context - // we will ensure the edge remains - sourceRes, err := eval.Solution.RawView().Vertex(v.SatisfactionEdge.Source) - if err != nil { - return fmt.Errorf("could not find source resource %s: %w", v.SatisfactionEdge.Source, err) - } - targetRes, err := eval.Solution.RawView().Vertex(v.SatisfactionEdge.Target) - if err != nil { - return fmt.Errorf("could not find target resource %s: %w", v.SatisfactionEdge.Target, err) - } - if sourceRes.Imported && targetRes.Imported { - return eval.Solution.RawView().AddEdge(v.SatisfactionEdge.Source, v.SatisfactionEdge.Target) - } - runner := &pathExpandVertexRunner{Eval: eval} edgeExpander := &path_selection.EdgeExpand{Ctx: eval.Solution} return v.runEvaluation(eval, runner, edgeExpander) diff --git a/pkg/infra/iac/templates/aws/rds_instance/factory.ts b/pkg/infra/iac/templates/aws/rds_instance/factory.ts index 86ee2e7dc..b169675cf 100644 --- a/pkg/infra/iac/templates/aws/rds_instance/factory.ts +++ b/pkg/infra/iac/templates/aws/rds_instance/factory.ts @@ -56,7 +56,7 @@ function create(args: Args): aws.rds.Instance { function properties(object: aws.rds.Instance, args: Args) { return { Username: object.username, - Password: object.password, + Password: object.password.apply((password) => password || ''), CredentialsSecretValue: pulumi.jsonStringify({ username: object.username, password: object.password, diff --git a/pkg/infra/iac/templates/aws/rds_subnet_group/factory.ts b/pkg/infra/iac/templates/aws/rds_subnet_group/factory.ts index adc8ac26f..ec80206bc 100644 --- a/pkg/infra/iac/templates/aws/rds_subnet_group/factory.ts +++ b/pkg/infra/iac/templates/aws/rds_subnet_group/factory.ts @@ -16,3 +16,15 @@ function create(args: Args): aws.rds.SubnetGroup { //TMPL {{- end }} }) } + +function properties(object: aws.rds.SubnetGroup, args: Args) { + return { + DeployedName: object.name, + } +} + +type AllProperties = Args & ReturnType + +function importResource(args: AllProperties): aws.rds.SubnetGroup { + return aws.rds.SubnetGroup.get(args.Name, args.DeployedName) +} \ No newline at end of file diff --git a/pkg/infra/state_reader/state_template/mappings/pulumi/rds_subnet_group.yaml b/pkg/infra/state_reader/state_template/mappings/pulumi/rds_subnet_group.yaml new file mode 100644 index 000000000..9b13477ad --- /dev/null +++ b/pkg/infra/state_reader/state_template/mappings/pulumi/rds_subnet_group.yaml @@ -0,0 +1,6 @@ +qualified_type_name: aws:rds_subnet_group +iac_qualified_type: aws:rds/subnetGroup:SubnetGroup + +property_mappings: + tags: Tags + name: DeployedName \ No newline at end of file diff --git a/pkg/templates/aws/resources/rds_subnet_group.yaml b/pkg/templates/aws/resources/rds_subnet_group.yaml index ff9ce6051..d573007b2 100644 --- a/pkg/templates/aws/resources/rds_subnet_group.yaml +++ b/pkg/templates/aws/resources/rds_subnet_group.yaml @@ -12,6 +12,12 @@ sanitize_name: }} properties: + DeployedName: + type: string + configuration_disabled: true + deploy_time: true + required: true + Subnets: type: list(resource(aws:subnet)) operational_rule: