Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 66a93e4

Browse files
support imported edges (#960)
1 parent 24f68e6 commit 66a93e4

File tree

9 files changed

+84
-3
lines changed

9 files changed

+84
-3
lines changed

pkg/engine/operational_eval/vertex_path_expand.go

+14
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ func (v *pathExpandVertex) Key() Key {
4747
}
4848

4949
func (v *pathExpandVertex) Evaluate(eval *Evaluator) error {
50+
// if both the source and target are imported resources we can skip the evaluation since its just for context
51+
// we will ensure the edge remains
52+
sourceRes, err := eval.Solution.RawView().Vertex(v.SatisfactionEdge.Source)
53+
if err != nil {
54+
return fmt.Errorf("could not find source resource %s: %w", v.SatisfactionEdge.Source, err)
55+
}
56+
targetRes, err := eval.Solution.RawView().Vertex(v.SatisfactionEdge.Target)
57+
if err != nil {
58+
return fmt.Errorf("could not find target resource %s: %w", v.SatisfactionEdge.Target, err)
59+
}
60+
if sourceRes.Imported && targetRes.Imported {
61+
return eval.Solution.RawView().AddEdge(v.SatisfactionEdge.Source, v.SatisfactionEdge.Target)
62+
}
63+
5064
runner := &pathExpandVertexRunner{Eval: eval}
5165
edgeExpander := &path_selection.EdgeExpand{Ctx: eval.Solution}
5266
return v.runEvaluation(eval, runner, edgeExpander)

pkg/engine/solution_context.go

+14
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ func (ctx solutionContext) LoadGraph(graph construct.Graph) error {
101101
}
102102
for _, edge := range edges {
103103
edgeTemplate := ctx.KB.GetEdgeTemplate(edge.Source, edge.Target)
104+
src, err := graph.Vertex(edge.Source)
105+
if err != nil {
106+
return err
107+
}
108+
dst, err := graph.Vertex(edge.Target)
109+
if err != nil {
110+
return err
111+
}
112+
if src.Imported && dst.Imported {
113+
if err := raw.AddEdge(edge.Source, edge.Target); err != nil {
114+
return err
115+
}
116+
continue
117+
}
104118
if edgeTemplate == nil {
105119
return fmt.Errorf("edge template %s -> %s not found", edge.Source, edge.Target)
106120
}

pkg/engine/solution_context/view_raw.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ func (view RawAccessView) RemoveVertex(hash construct.ResourceId) error {
101101
func (view RawAccessView) AddEdge(source, target construct.ResourceId, options ...func(*graph.EdgeProperties)) error {
102102
dfErr := view.inner.DataflowGraph().AddEdge(source, target, options...)
103103

104+
// check to see if both resources are imported and if so allow the edge
105+
src, err := view.inner.DataflowGraph().Vertex(source)
106+
if err != nil {
107+
return err
108+
}
109+
dst, err := view.inner.DataflowGraph().Vertex(target)
110+
if err != nil {
111+
return err
112+
}
113+
if src.Imported && dst.Imported {
114+
// don't need to add it to the deployment graph - if both resources are imported, then
115+
// they don't need each other since neither are technically being deployed.
116+
return nil
117+
}
118+
104119
var deplErr error
105120
et := view.inner.KnowledgeBase().GetEdgeTemplate(source, target)
106121
srcRt, terr := view.inner.KnowledgeBase().GetResourceTemplate(source)
@@ -122,7 +137,6 @@ func (view RawAccessView) AddEdge(source, target construct.ResourceId, options .
122137
}
123138
}
124139

125-
var err error
126140
if dfErr != nil && !errors.Is(dfErr, graph.ErrEdgeAlreadyExists) {
127141
err = errors.Join(err, dfErr)
128142
}

pkg/infra/iac/templates/aws/cloudfront_distribution/factory.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ function create(args: Args): aws.cloudfront.Distribution {
4747
})
4848
}
4949

50-
function properties(object: ReturnType<typeof create>, args: Args) {}
50+
function properties(object: ReturnType<typeof create>, args: Args) {
51+
return {
52+
DomainName: object.domainName,
53+
URLBase: pulumi.interpolate`https://${object.domainName}`,
54+
}
55+
}
5156

5257
function infraExports(
5358
object: ReturnType<typeof create>,

pkg/infra/iac/templates/aws/ecs_service/factory.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface Args {
1616
Subnets: aws.ec2.Subnet[]
1717
TaskDefinition: aws.ecs.TaskDefinition
1818
Name: string
19+
HealthCheckGracePeriodSeconds: number
1920
LoadBalancers: TemplateWrapper<any[]>
2021
dependsOn?: pulumi.Input<pulumi.Input<pulumi.Resource>[]> | pulumi.Input<pulumi.Resource>
2122
ServiceRegistries: pulumi.Input<awsInputs.ecs.ServiceServiceRegistries>
@@ -39,6 +40,9 @@ function create(args: Args): aws.ecs.Service {
3940
//TMPL {{- if .EnableExecuteCommand }}
4041
enableExecuteCommand: args.EnableExecuteCommand,
4142
//TMPL {{- end }}
43+
//TMPL {{- if .HealthCheckGracePeriodSeconds }}
44+
healthCheckGracePeriodSeconds: args.HealthCheckGracePeriodSeconds,
45+
//TMPL {{- end }}
4246
forceNewDeployment: args.ForceNewDeployment,
4347
//TMPL {{- if .LoadBalancers }}
4448
loadBalancers: args.LoadBalancers,

pkg/infra/iac/templates/aws/memorydb_cluster/factory.ts

+6
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,11 @@ function properties(object: aws.memorydb.Cluster, args: Args) {
9999
}
100100
return endpointStrings.join(',')
101101
})}`,
102+
PrimaryAddress: pulumi.interpolate`${object.clusterEndpoints.apply(
103+
(endpoint) => endpoint[0].address
104+
)}`,
105+
PrimaryPort: pulumi.interpolate`${object.clusterEndpoints.apply(
106+
(endpoint) => endpoint[0].port
107+
)}`,
102108
}
103109
}

pkg/templates/aws/resources/cloudfront_distribution.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ properties:
187187
type: string
188188
aws:tags:
189189
type: model
190+
DomainName:
191+
type: string
192+
description: |
193+
The domain name of the distribution. For example: d111111abcdef8.cloudfront.net.
194+
deploy_time: true
195+
configuration_disabled: true
196+
URLBase:
197+
type: string
198+
description: |
199+
The base URL for the distribution. For example: https://d111111abcdef8.cloudfront.net.
200+
deploy_time: true
201+
configuration_disabled: true
190202

191203
path_satisfaction:
192204
as_source:

pkg/templates/aws/resources/ecs_service.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ properties:
3131
type: bool
3232
default_value: false
3333
description: Whether to enable Amazon ECS Exec for the service. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html
34+
HealthCheckGracePeriodSeconds:
35+
type: int
36+
description: Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 2147483647. Only valid for services configured to use load balancers.
3437
ForceNewDeployment:
3538
type: bool
3639
default_value: true
@@ -77,7 +80,6 @@ properties:
7780
resources:
7881
- aws:ecs_task_definition:{{ .Self.Name }}
7982
unique: true
80-
8183
description: The family and revision (family:revision) or full Amazon Resource
8284
Name (ARN) of the task definition to run in the service
8385
ServiceRegistries:

pkg/templates/aws/resources/memorydb_cluster.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ properties:
107107
description: The endpoints of the cluster as a string.
108108
configuration_disabled: true
109109
deploy_time: true
110+
PrimaryAddress:
111+
type: string
112+
description: The address of the primary node.
113+
configuration_disabled: true
114+
deploy_time: true
115+
PrimaryPort:
116+
type: int
117+
description: The port number of the primary node.
118+
configuration_disabled: true
119+
deploy_time: true
110120

111121
consumption:
112122
emitted:

0 commit comments

Comments
 (0)