CF cannot preprocess the stack when a module parameter appears in the conditions block and using a !Ref or !GetAtt function
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne damit, den Fehler mit module1.yml, module2.yml und der übergeordneten Vorlage zu reproduzieren, indem du den Befehlen cfn init, validate und submit folgst, bevor du den Test-Stack erstellst. Verfolge, wie der Modulparameter und die Bedingung verarbeitet werden, und überprüfe anschließend, dass der Stack ohne den Fehler wegen nicht aufgelöster Abhängigkeiten erstellt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
When using a CF module, if you use an intrincic function expression to assign the value of module parameter, and the template source of the module uses the parameter name in a condition, CF cannot preprocess the stack and exits with error
CloudFormation failed to preprocess the stack:
Template format error:
Unresolved dependencies [resSampleModule1resSourceQueue]. Cannot reference resources in the Conditions block of the template
Steps to reproduce
1. Create a module called Fujitsu::CF::SampleModule1::MODULE using the template module1.yml as fragment:
module1.yml
===========
AWSTemplateFormatVersion: 2010-09-09
Description: "Template to generate an example module with name Fujitsu::CF::SampleModule1::MODULE"
Parameters:
parMaxReceiveCount:
Description: Number of times a message is received by a consumer of the source queue before being moved to the dead-letter queue
Type: Number
Default: 3
Resources:
resDeadLetterQueue:
Type: AWS::SQS::Queue
resSourceQueue:
Type: AWS::SQS::Queue
Properties:
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- "resDeadLetterQueue"
- "Arn"
maxReceiveCount: !Ref parMaxReceiveCount
Commands:
mkdir module1
cd module1
cfn init -t Fujitsu::CF::SampleModule1::MODULE -a MODULE --region eu-west-1
Replace fragmets/sample.json with module1.yml
cfn validate
cfn submit --region eu-west-1 --set-default
2. Create a module called Fujitsu::CF::SampleModule2::MODULE using the template module2.yml as fragment:
module2.yml
===========
AWSTemplateFormatVersion: 2010-09-09
Description: "Template to generate a samplemodule with name Fujitsu::CF::SampleModule2::MODULE"
Parameters:
parBucketName:
Description: S3 bucket name. If not specified, the S3 service assigns a name
Type: String
parVersioningConfiguration:
Description: If versioning is enabled (Enabled) or disabled (Suspended)
Type: String
AllowedValues: ["Enabled","Suspended"]
Conditions:
cndIsBucketNameSpecified: !Not
- !Equals
- ""
- !Ref parBucketName
Resources:
resS3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !If
- cndIsBucketNameSpecified
- !Sub ${parBucketName}-${AWS::Region}-${AWS::AccountId}
- !Ref AWS::NoValue
VersioningConfiguration:
Status: !Ref parVersioningConfiguration
Outputs:
outBucketName:
Description: S3 bucket name
Value: !Ref resS3Bucket
Commands:
mkdir module2
cd module2
cfn init -t Fujitsu::CF::SampleModule2::MODULE -a MODULE --region eu-west-1
Replace fragmets/sample.json with module2.yml
cfn validate
cfn submit --region eu-west-1 --set-default
3. Create a stack (called test in the image), from this template:
AWSTemplateFormatVersion: 2010-09-09
Description: "Sample parent template that uses Fujitsu::CF::SampleModule1::MODULE and Fujitsu::CF::SampleModule2::MODULE"
Parameters:
parMaxReceiveCount:
Description: Number of times a message is received by a consumer of the source queue before being moved to the dead-letter queue
Type: Number
Default: 3
Resources:
resSampleModule1:
Type: Fujitsu::CF::SampleModule1::MODULE
Properties:
parMaxReceiveCount: !Ref parMaxReceiveCount
resSampleModule2:
Type: Fujitsu::CF::SampleModule2::MODULE
Properties:
parBucketName: !GetAtt [resSampleModule1, resSourceQueue.QueueName]
parVersioningConfiguration: "Suspended"
I will refer to this as the 'parent template'.
Expected behavior
The stack is created without errors.
Actual behavior
CF reports an error:
CloudFormation failed to preprocess the stack:
Template format error:
Unresolved dependencies [resSampleModule1resSourceQueue]. Cannot reference resources in the Conditions block of the template
The problem is the parent template uses an intrinsic function expression to assign value to a module parameter (parBucketName: !GetAtt [resSampleModule1, resSourceQueue.QueueName]), and the template fragment of the module uses the name of the assigned parameter (parBucketName) in a condition (cndIsBucketNameSpecified).
I think this is a bug because parBucketName in template fragment must be a name internal to the module.
- Vorherrschende Sprache
- Python
- Sterne
- 336
- Forks
- 173
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws-cloudformation/cloudformation-cli
-
docs: `--use-docker` and `--no-docker` options of `cfn submit` are missing from the documentationOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
aws-cloudformation/cloudformation-cli#1117 · 1 Kommentar · 6 Reaktionen ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
aws-cloudformation/cloudformation-cli#1115 · 1 Kommentar · 9 Reaktionen ·
Alle Issues in aws-cloudformation/cloudformation-cli
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
521xueweihan/HelloGitHub#4385 ·
-
🐛 bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
pdm-project/pdm#4012 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
pollen-robotics/reachy_mini_conversation_app#611 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 91/100
aws-samples/sample-per-model-bedrock#913 ·
Maintainer antworten meist innerhalb von 1 Tag
-
lesson-submission pending-review
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
Ikalus1988/MisakaNet#5115 ·
Maintainer antworten meist innerhalb von 1 Tag