diff --git a/cft/pkg/module.go b/cft/pkg/module.go index 02bd120a..937702e3 100644 --- a/cft/pkg/module.go +++ b/cft/pkg/module.go @@ -70,7 +70,11 @@ func addPolicy(ext *yaml.Node, name string, moduleExtension *yaml.Node, template // Rename a resource defined in the module to add the template resource name func rename(logicalId string, resourceName string) string { - return logicalId + resourceName + if resourceName == "ModuleExtension" { + return logicalId + } else { + return logicalId + resourceName + } } // Recursive function to find all refs in properties @@ -228,11 +232,6 @@ func processModule(module *yaml.Node, return false, errors.New("expected ModuleExtension.Metadata.Extends") } - _, moduleProps := s11n.GetMapValue(moduleExtension, "Properties") - if moduleProps == nil { - return false, errors.New("expected ModuleExtension.Properties") - } - // Create a new node to contain the extended resource. // This will be added to the template, and the original resource node will be removed ext := &yaml.Node{} diff --git a/test/modules/bucket.yaml b/test/modules/bucket.yaml index 51e0fe7c..0d918748 100644 --- a/test/modules/bucket.yaml +++ b/test/modules/bucket.yaml @@ -76,4 +76,9 @@ Resources: AdditionalResource2: Type: AWS::S3::Bucket + DependsOnModuleExtension: + Type: AWS::S3::Bucket + DependsOn: ModuleExtension + + diff --git a/test/modules/expect.yaml b/test/modules/expect.yaml index fafca969..0c1570c7 100644 --- a/test/modules/expect.yaml +++ b/test/modules/expect.yaml @@ -69,6 +69,11 @@ Resources: ModuleExampleAdditionalResource2: Type: AWS::S3::Bucket + ModuleExampleDependsOnModuleExtension: + Type: AWS::S3::Bucket + DependsOn: + - ModuleExample + WithoutExtensionBucketA: Type: AWS::S3::Bucket Properties: diff --git a/test/modules/ext-ref.yaml b/test/modules/ext-ref.yaml new file mode 100644 index 00000000..e327dd5e --- /dev/null +++ b/test/modules/ext-ref.yaml @@ -0,0 +1,15 @@ +Description: | + For testing Refs on the ModuleExtension itself + +Resources: + + ModuleExtension: + Metadata: + Extends: AWS::S3::Bucket + + DependsOnModuleExtension: + Type: AWS::S3::Bucket + DependsOn: ModuleExtension + + + diff --git a/test/templates/ext-ref-module.yaml b/test/templates/ext-ref-module.yaml new file mode 100644 index 00000000..6bc3e8d5 --- /dev/null +++ b/test/templates/ext-ref-module.yaml @@ -0,0 +1,8 @@ +Resources: + + ModuleExample: + Type: !Rain::Module "file://../../modules/ext-ref.yaml" + Properties: + BucketName: ezbeard-cep-test-module-bucket + +