troposphere icon indicating copy to clipboard operation
troposphere copied to clipboard

ECR CRR ReplicationConfiguration.ReplicationConfiguration has incorrect name (ReplicationConfigurationProperty)

Open TsimpDim opened this issue 4 years ago • 1 comments

As per the spec, this property is:

    "AWS::ECR::ReplicationConfiguration.ReplicationConfiguration": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-replicationconfiguration-replicationconfiguration.html",
      "Properties": {
        "Rules": {
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-replicationconfiguration-replicationconfiguration.html#cfn-ecr-replicationconfiguration-replicationconfiguration-rules",
          "UpdateType": "Mutable",
          "Required": true,
          "Type": "List",
          "ItemType": "ReplicationRule"
        }
      }
    }

however in the codebase it is called ReplicationConfigurationProperty

Relevant lines: https://github.com/cloudtools/troposphere/blob/f286aed5a9e09d1b2337fceec51d169bf2faddfe/troposphere/ecr.py#L60-L65

I understand this could be fixed by adding a file for ecr under script/patches, is that correct?

For me this connects to #1993 as I found them when adding CRR to a project. Let me know how I can help :)

TsimpDim avatar Dec 28 '21 15:12 TsimpDim

Thank you for the issue. I fixed the other issue but left this one due to backward compatibility. I noted it in the patches so I can change it in a future major version.

markpeek avatar Dec 28 '21 16:12 markpeek

Also experienced this issue today, not sure how to work around it.

        replication_configuration: ecr.ReplicationConfiguration = ecr.ReplicationConfiguration(
            "ReplicationConfiguration",
            ReplicationConfigurationProperty=ecr.ReplicationConfigurationProperty(
                Rules=[
                    ecr.ReplicationRule(
                        Destinations=[
                            ...
                        ],
                    )
                ]
            ),
        )
        template.add_resource(replication_configuration)

Generated CloudFormation:

Resources:
  ReplicationConfiguration:
    Properties:
      ReplicationConfigurationProperty:
        Rules:
          - Destinations:
              ...
    Type: AWS::ECR::ReplicationConfiguration

In CloudFormation:

Properties validation failed for resource SharedReplicationConfiguration with message: #: required key [ReplicationConfiguration] not found #: extraneous key [ReplicationConfigurationProperty] is not permitted

Is this still planned to be fixed in a future release? Any guidance towards configuring repository replication in Troposphere in the meantime?

spacez320 avatar Sep 07 '23 14:09 spacez320

Hopefully you could give me a quick confirmation on if this works. I removed the backward compatibility since that likely doesn't work at all anyway...

$ git diff
diff --git a/scripts/patches/ecr.py b/scripts/patches/ecr.py
index 7171727..27fcaa5 100644
--- a/scripts/patches/ecr.py
+++ b/scripts/patches/ecr.py
@@ -10,10 +10,4 @@ patches = [
         "path": "/ResourceTypes/AWS::ECR::ReplicationConfiguration/Properties/ReplicationConfiguration/Type",
         "value": "ReplicationConfigurationProperty",
     },
-    # backward compatibility
-    {
-        "op": "move",
-        "from": "/ResourceTypes/AWS::ECR::ReplicationConfiguration/Properties/ReplicationConfiguration",
-        "path": "/ResourceTypes/AWS::ECR::ReplicationConfiguration/Properties/ReplicationConfigurationProperty",
-    },
 ]
diff --git a/troposphere/ecr.py b/troposphere/ecr.py
index 53cd394..9b95c36 100644
--- a/troposphere/ecr.py
+++ b/troposphere/ecr.py
@@ -116,7 +116,7 @@ class ReplicationConfiguration(AWSObject):
     resource_type = "AWS::ECR::ReplicationConfiguration"

     props: PropsDictType = {
-        "ReplicationConfigurationProperty": (ReplicationConfigurationProperty, True),
+        "ReplicationConfiguration": (ReplicationConfigurationProperty, True),
     }

You could make the change to the patch file and then run in a checked out troposphere repo with the requirements installed:

make spec
make regen

Or make the manual change to troposphere/ecr.py in your installed version.

Let me know if that works and I can create a new release.

markpeek avatar Sep 07 '23 15:09 markpeek

@markpeek Your diff worked great! At least it got through to CloudFormation and CF set up the replication rule. Have yet to actually see the replication in action, but CF at least accepts the generated template now.

spacez320 avatar Sep 08 '23 15:09 spacez320

@spacez320 thank you for the confirmation. Fix via 3362e724c251563d3ee4ef439d39463a42669b67

markpeek avatar Sep 11 '23 01:09 markpeek