implement ref and getAtt for related resources#484
Open
gemammercado wants to merge 7 commits intomainfrom
Open
implement ref and getAtt for related resources#484gemammercado wants to merge 7 commits intomainfrom
gemammercado wants to merge 7 commits intomainfrom
Conversation
satyakigh
reviewed
Mar 18, 2026
8780f05 to
0505e8e
Compare
chrisqm-dev
reviewed
Apr 1, 2026
0505e8e to
60f603c
Compare
60f603c to
76d43f5
Compare
chrisqm-dev
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
Auto-populate
!Refand!GetAttin related resource snippetsWhen inserting related resources, properties that reference the parent resource type are now pre-populated with
!Refor!GetAttintrinsic functions instead of empty strings.Changes
src/relatedResources/RelatedResourcesSnippetProvider.tsRelationshipSchemaServiceas a constructor dependencyfindParentLogicalId()to resolve the parent resource's logical ID from the template syntax treegetPropertyValueForRelatedResource()to check if a required property references the parent type and generate the appropriate intrinsic functionbuildIntrinsicReference()to decide between!Ref(primary identifier match) and!GetAtt(non-primary attribute likeArn)replaceIntrinsicPlaceholders()to handle YAML serialization (the YAML library quotes!prefixed values, so placeholders are used during serialization and replaced afterward)addParentReferencingProperties()to also populate non-required properties that reference the parentcountTopLevelParentReferences()guard: when multiple top-level properties reference the same parent (ambiguous), none are auto-populatedsrc/handlers/RelatedResourcesHandler.tshasExactlyOnePopulatableRelationship()filter to thegetRelatedResourceTypeshandlerIn this example, the reference can go in AdminRole or ExecutionRole, but the code populates AdminRole because it is a top-level property.
src/server/CfnLspProviders.tsrelationshipSchemaServiceto theRelatedResourcesSnippetProviderconstructorsrc/services/RelationshipSchemaService.tsAWS::IAM::ManagedPolicy. ButAWS::Lambda::Functionhas aRoleproperty that points back to IAM::Role. The reverse cache captures this incoming directionExample
Before:
After:
For JSON templates, produces
{"Ref": "LogicalId"}or{"Fn::GetAtt": ["LogicalId", "Attribute"]}.Testing
AWS::IAM::Role,AWS::EC2::VPC, andAWS::S3::Bucketparent types with full related resource insertionKnown limitations
These are pre-existing data quality issues in
relationship_schemas.json, not introduced by this PR:ServiceCatalog::StackSetConstraint— MissingExecutionRole → IAM::Rolerelationship; onlyAdminRoleis declaredSSM::ParameterValue — Maps to 100+ resource types; overly broad relationshipEC2::EIPDomain — Incorrectly maps toAWS::EC2::VPC; Domain is an enum, not a VPC IDGlue::CrawlerDatabaseName — Incorrectly maps toAWS::S3::Bucket; expects a Glue Database name!Ref/!GetAtt(future enhancement: let user choose which)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.