@@ -2242,24 +2242,24 @@ func (c *FlowContext) ensureEfs(ctx context.Context) error {
22422242 efsID := c .config .ElasticFileSystem .ID
22432243 log .Info ("discovering existing EFS mount targets" , "fileSystemID" , * efsID )
22442244
2245- mountTargetOutput , err := c .client .DescribeMountTargetsEfs (ctx , & efs.DescribeMountTargetsInput {
2246- FileSystemId : efsID ,
2247- })
2245+ mountTargetOutput , err := c .client .GetMountTargetsEfs (ctx , * efsID )
22482246 if err != nil {
2249- return fmt .Errorf ("failed to describe mount targets for EFS %s: %w" , * efsID , err )
2247+ return fmt .Errorf ("failed to get mount targets for EFS %s: %w" , * efsID , err )
2248+ }
2249+ if mountTargetOutput == nil {
2250+ return fmt .Errorf ("found no mount targets for EFS %s" , * efsID )
22502251 }
22512252
22522253 childMountTargets := c .state .GetChild (ChildEfsMountTargets )
2253- if mountTargetOutput != nil {
2254- for _ , mt := range mountTargetOutput .MountTargets {
2255- if mt .MountTargetId != nil && mt .SubnetId != nil {
2256- // Key format differs from managed path (which uses efsID_subnetID_sgID) because
2257- // BYO discovery is read-only — we never create or delete these mount targets.
2258- // The key only needs to be unique for state storage, not match the managed format.
2259- key := fmt .Sprintf ("%s_%s" , * efsID , * mt .SubnetId )
2260- childMountTargets .Set (key , * mt .MountTargetId )
2261- log .Info ("discovered EFS mount target" , "mountTargetID" , * mt .MountTargetId , "subnetID" , * mt .SubnetId , "az" , ptr .Deref (mt .AvailabilityZoneName , "" ))
2262- }
2254+ for _ , mt := range mountTargetOutput .MountTargets {
2255+ if mt .MountTargetId != nil && mt .SubnetId != nil {
2256+ // Key format differs from managed path (which uses efsID_subnetID_sgID) because
2257+ // BYO discovery is read-only — we never create or delete these mount targets.
2258+ // The key only needs to be unique for state storage, not match the managed format.
2259+ key := fmt .Sprintf ("%s_%s" , * efsID , * mt .SubnetId )
2260+ childMountTargets .Set (key , * mt .MountTargetId )
2261+ log .Info ("discovered EFS mount target" , "mountTargetID" , * mt .MountTargetId ,
2262+ "subnetID" , * mt .SubnetId , "az" , ptr .Deref (mt .AvailabilityZoneName , "" ))
22632263 }
22642264 }
22652265 }
@@ -2278,6 +2278,7 @@ func (c *FlowContext) ensureEfs(ctx context.Context) error {
22782278func (c * FlowContext ) ensureEfsCreateFileSystem (ctx context.Context ) error {
22792279 log := LogFromContext (ctx )
22802280
2281+ // returns nil error if not found
22812282 current , err := FindExisting (ctx , c .state .Get (IdentifierManagedEfsID ), c .commonTags .AddManagedTag (),
22822283 c .client .GetFileSystem , c .client .FindFileSystemsByTags )
22832284 if err != nil {
0 commit comments