failing snapshot for change in hashes of AssetParameters
Snapshot aren't matching on the CI because of changes in the hashes of AssetParameters Ref ignoreAssets: true is already defined and not fixing this. Is this something fixable with Property matchers?

What are you building there? Can you show more of the cloudformation?
Here it is @hupe1980 . The part that is changing is the hash of a Parameters containing a Ref to a S3Bucket. I'm using AWS CDK packages version 1.39.0
What are you building there? Can you show more of the cloudformation?
Here is the generated CloudFormation template in .json
{
"Resources": {
"BucketAssetsC2D5BF55": {
"Type": "AWS::S3::Bucket",
"Properties": {
"CorsConfiguration": {
"CorsRules": [
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"*"
]
}
]
},
"WebsiteConfiguration": {
"ErrorDocument": "index.html",
"IndexDocument": "index.html"
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "whitelabel-staging/BucketAssets/Resource"
}
},
"BucketAssetsPolicy1CBA853C": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": {
"Ref": "BucketAssetsC2D5BF55"
},
"PolicyDocument": {
"Statement": [
{
"Action": "s3:GetObject",
"Effect": "Allow",
"Principal": "*",
"Resource": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"BucketAssetsC2D5BF55",
"Arn"
]
},
"/*"
]
]
}
}
],
"Version": "2012-10-17"
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/BucketAssets/Policy/Resource"
}
},
"LambdaIndexServiceRoleF03962BE": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/LambdaIndex/ServiceRole/Resource"
}
},
"LambdaIndexA8DA64AF": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParametersfe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370S3BucketAB59F276"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersfe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370S3VersionKey6E10A54E"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersfe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370S3VersionKey6E10A54E"
}
]
}
]
}
]
]
}
},
"Handler": "handler.default",
"Role": {
"Fn::GetAtt": [
"LambdaIndexServiceRoleF03962BE",
"Arn"
]
},
"Runtime": "nodejs12.x",
"FunctionName": "whitelabel-staging-index",
"MemorySize": 512,
"Timeout": 30
},
"DependsOn": [
"LambdaIndexServiceRoleF03962BE"
],
"Metadata": {
"aws:cdk:path": "whitelabel-staging/LambdaIndex/Resource",
"aws:asset:path": "asset.fe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370",
"aws:asset:property": "Code"
}
},
"CloudfrontAssetsCFDistribution3CAF4846": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"Aliases": [
"whitelabel-assets.mydomain-staging.com"
],
"DefaultCacheBehavior": {
"AllowedMethods": [
"GET",
"HEAD",
"OPTIONS"
],
"CachedMethods": [
"GET",
"HEAD"
],
"Compress": true,
"ForwardedValues": {
"Cookies": {
"Forward": "none"
},
"QueryString": false
},
"TargetOriginId": "origin1",
"ViewerProtocolPolicy": "redirect-to-https"
},
"DefaultRootObject": "index.html",
"Enabled": true,
"HttpVersion": "http2",
"IPV6Enabled": true,
"Origins": [
{
"DomainName": {
"Fn::GetAtt": [
"BucketAssetsC2D5BF55",
"RegionalDomainName"
]
},
"Id": "origin1",
"S3OriginConfig": {}
}
],
"PriceClass": "PriceClass_All",
"ViewerCertificate": {
"AcmCertificateArn": "arn:aws:acm:us-east-1:911169584699:certificate/ce82d11b-93e6-49d6-b3a0-a186069a17be",
"MinimumProtocolVersion": "TLSv1.1_2016",
"SslSupportMethod": "sni-only"
}
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/CloudfrontAssets/CFDistribution"
}
},
"RestApi0C43BF4B": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"BinaryMediaTypes": [
"*/*"
],
"Name": "whitelabel-staging"
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Resource"
}
},
"RestApiCloudWatchRoleE3ED6605": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "apigateway.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs"
]
]
}
]
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/CloudWatchRole/Resource"
}
},
"RestApiAccount7C83CF5A": {
"Type": "AWS::ApiGateway::Account",
"Properties": {
"CloudWatchRoleArn": {
"Fn::GetAtt": [
"RestApiCloudWatchRoleE3ED6605",
"Arn"
]
}
},
"DependsOn": [
"RestApi0C43BF4B"
],
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Account"
}
},
"RestApiDeployment180EC5038e7c360fcd3f1dce4f6f46203132e6ed": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
"Ref": "RestApi0C43BF4B"
},
"Description": "Automatically created by the RestApi construct"
},
"DependsOn": [
"RestApiproxyANY1786B242",
"RestApiproxyC95856DD",
"RestApiANYA7C1DC94"
],
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Deployment/Resource"
}
},
"RestApiDeploymentStageprod3855DE66": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"RestApiId": {
"Ref": "RestApi0C43BF4B"
},
"DeploymentId": {
"Ref": "RestApiDeployment180EC5038e7c360fcd3f1dce4f6f46203132e6ed"
},
"StageName": "prod"
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/DeploymentStage.prod/Resource"
}
},
"RestApiCustomDomain91FA5E60": {
"Type": "AWS::ApiGateway::DomainName",
"Properties": {
"DomainName": "*.mydomain-staging.com",
"CertificateArn": "arn:aws:acm:us-east-1:911169584699:certificate/ce82d11b-93e6-49d6-b3a0-a186069a17be",
"EndpointConfiguration": {
"Types": [
"EDGE"
]
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/CustomDomain/Resource"
}
},
"RestApiCustomDomainMapwhitelabelstagingRestApi2B9E6825B6512D65": {
"Type": "AWS::ApiGateway::BasePathMapping",
"Properties": {
"DomainName": {
"Ref": "RestApiCustomDomain91FA5E60"
},
"RestApiId": {
"Ref": "RestApi0C43BF4B"
},
"Stage": {
"Ref": "RestApiDeploymentStageprod3855DE66"
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/CustomDomain/Map:--=>whitelabelstagingRestApi2B9E6825/Resource"
}
},
"RestApiproxyC95856DD": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"ParentId": {
"Fn::GetAtt": [
"RestApi0C43BF4B",
"RootResourceId"
]
},
"PathPart": "{proxy+}",
"RestApiId": {
"Ref": "RestApi0C43BF4B"
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/{proxy+}/Resource"
}
},
"RestApiproxyANYApiPermissionwhitelabelstagingRestApi2B9E6825ANYproxy37D8D669": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"LambdaIndexA8DA64AF",
"Arn"
]
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":execute-api:us-east-1:911169584699:",
{
"Ref": "RestApi0C43BF4B"
},
"/",
{
"Ref": "RestApiDeploymentStageprod3855DE66"
},
"/*/{proxy+}"
]
]
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/{proxy+}/ANY/ApiPermission.whitelabelstagingRestApi2B9E6825.ANY..{proxy+}"
}
},
"RestApiproxyANYApiPermissionTestwhitelabelstagingRestApi2B9E6825ANYproxy474C9F86": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"LambdaIndexA8DA64AF",
"Arn"
]
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":execute-api:us-east-1:911169584699:",
{
"Ref": "RestApi0C43BF4B"
},
"/test-invoke-stage/*/{proxy+}"
]
]
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/{proxy+}/ANY/ApiPermission.Test.whitelabelstagingRestApi2B9E6825.ANY..{proxy+}"
}
},
"RestApiproxyANY1786B242": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"HttpMethod": "ANY",
"ResourceId": {
"Ref": "RestApiproxyC95856DD"
},
"RestApiId": {
"Ref": "RestApi0C43BF4B"
},
"AuthorizationType": "NONE",
"Integration": {
"IntegrationHttpMethod": "POST",
"Type": "AWS_PROXY",
"Uri": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":apigateway:us-east-1:lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"LambdaIndexA8DA64AF",
"Arn"
]
},
"/invocations"
]
]
}
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/{proxy+}/ANY/Resource"
}
},
"RestApiANYApiPermissionwhitelabelstagingRestApi2B9E6825ANY14EAEAC7": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"LambdaIndexA8DA64AF",
"Arn"
]
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":execute-api:us-east-1:911169584699:",
{
"Ref": "RestApi0C43BF4B"
},
"/",
{
"Ref": "RestApiDeploymentStageprod3855DE66"
},
"/*/"
]
]
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/ANY/ApiPermission.whitelabelstagingRestApi2B9E6825.ANY.."
}
},
"RestApiANYApiPermissionTestwhitelabelstagingRestApi2B9E6825ANY131D7F26": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"LambdaIndexA8DA64AF",
"Arn"
]
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":execute-api:us-east-1:911169584699:",
{
"Ref": "RestApi0C43BF4B"
},
"/test-invoke-stage/*/"
]
]
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/ANY/ApiPermission.Test.whitelabelstagingRestApi2B9E6825.ANY.."
}
},
"RestApiANYA7C1DC94": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"HttpMethod": "ANY",
"ResourceId": {
"Fn::GetAtt": [
"RestApi0C43BF4B",
"RootResourceId"
]
},
"RestApiId": {
"Ref": "RestApi0C43BF4B"
},
"AuthorizationType": "NONE",
"Integration": {
"IntegrationHttpMethod": "POST",
"Type": "AWS_PROXY",
"Uri": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":apigateway:us-east-1:lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"LambdaIndexA8DA64AF",
"Arn"
]
},
"/invocations"
]
]
}
}
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/RestApi/Default/ANY/Resource"
}
},
"BucketDeploymentAssetsCustomResource18D602EE": {
"Type": "Custom::CDKBucketDeployment",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536",
"Arn"
]
},
"SourceBucketNames": [
{
"Ref": "AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3BucketB744F6E7"
}
],
"SourceObjectKeys": [
{
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3VersionKeyC3EA3D96"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3VersionKeyC3EA3D96"
}
]
}
]
}
]
]
}
],
"DestinationBucketName": {
"Ref": "BucketAssetsC2D5BF55"
},
"SystemMetadata": {
"cache-control": "max-age=31536000, immutable"
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "whitelabel-staging/BucketDeploymentAssets/CustomResource/Default"
}
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/Resource"
}
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:GetObject*",
"s3:GetBucket*",
"s3:List*"
],
"Effect": "Allow",
"Resource": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":s3:::",
{
"Ref": "AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3BucketB744F6E7"
}
]
]
},
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":s3:::",
{
"Ref": "AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3BucketB744F6E7"
},
"/*"
]
]
}
]
},
{
"Action": [
"s3:GetObject*",
"s3:GetBucket*",
"s3:List*",
"s3:DeleteObject*",
"s3:PutObject*",
"s3:Abort*"
],
"Effect": "Allow",
"Resource": [
{
"Fn::GetAtt": [
"BucketAssetsC2D5BF55",
"Arn"
]
},
{
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"BucketAssetsC2D5BF55",
"Arn"
]
},
"/*"
]
]
}
]
}
],
"Version": "2012-10-17"
},
"PolicyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
"Roles": [
{
"Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
}
]
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/DefaultPolicy/Resource"
}
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3Bucket848A1F31"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96"
}
]
}
]
}
]
]
}
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
"Arn"
]
},
"Runtime": "python3.6",
"Timeout": 900
},
"DependsOn": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
],
"Metadata": {
"aws:cdk:path": "whitelabel-staging/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/Resource",
"aws:asset:path": "asset.3565eed5634972157639fd9710286d413e5689a74255ad06d33318dc7a9989cc.zip",
"aws:asset:property": "Code"
}
},
"DnsRecordAssets2781D238": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "whitelabel-assets.mydomain-staging.com.",
"Type": "A",
"AliasTarget": {
"DNSName": {
"Fn::GetAtt": [
"CloudfrontAssetsCFDistribution3CAF4846",
"DomainName"
]
},
"HostedZoneId": "Z2FDTNDATAQYW2"
},
"HostedZoneId": "ZHB5XQW8DTMOL"
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/DnsRecordAssets/Resource"
}
},
"DnsRecordSite4B742B94": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"Name": "*.mydomain-staging.com.",
"Type": "A",
"AliasTarget": {
"DNSName": {
"Fn::GetAtt": [
"RestApiCustomDomain91FA5E60",
"DistributionDomainName"
]
},
"HostedZoneId": {
"Fn::GetAtt": [
"RestApiCustomDomain91FA5E60",
"DistributionHostedZoneId"
]
}
},
"HostedZoneId": "ZHB5XQW8DTMOL"
},
"Metadata": {
"aws:cdk:path": "whitelabel-staging/DnsRecordSite/Resource"
}
}
},
"Parameters": {
"AssetParametersfe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370S3BucketAB59F276": {
"Type": "String",
"Description": "S3 bucket for asset \"fe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370\""
},
"AssetParametersfe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370S3VersionKey6E10A54E": {
"Type": "String",
"Description": "S3 key for asset version \"fe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370\""
},
"AssetParametersfe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370ArtifactHash25604A1A": {
"Type": "String",
"Description": "Artifact hash for asset \"fe6d38b1cbbe3d6c507574aa0efb4d89cb652778c95e3a258fe5aed5e94ed370\""
},
"AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3Bucket848A1F31": {
"Type": "String",
"Description": "S3 bucket for asset \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\""
},
"AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffS3VersionKey983DBE96": {
"Type": "String",
"Description": "S3 key for asset version \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\""
},
"AssetParametersa9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ffArtifactHash08605F5E": {
"Type": "String",
"Description": "Artifact hash for asset \"a9125fa9a40550c71cde90bd478cc23091e868067a12380c1df0827d013ad2ff\""
},
"AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3BucketB744F6E7": {
"Type": "String",
"Description": "S3 bucket for asset \"c5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6\""
},
"AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6S3VersionKeyC3EA3D96": {
"Type": "String",
"Description": "S3 key for asset version \"c5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6\""
},
"AssetParametersc5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6ArtifactHash1E7A4C98": {
"Type": "String",
"Description": "Artifact hash for asset \"c5100226e3441cc16e596f86cd9ed834d9329c8e1448d0b9f938847f68bd28b6\""
}
},
"Outputs": {
"RestApiEndpoint0551178A": {
"Value": {
"Fn::Join": [
"",
[
"https://",
{
"Ref": "RestApi0C43BF4B"
},
".execute-api.us-east-1.",
{
"Ref": "AWS::URLSuffix"
},
"/",
{
"Ref": "RestApiDeploymentStageprod3855DE66"
},
"/"
]
]
}
},
"urlassets": {
"Value": "https://whitelabel-assets.mydomain-staging.com"
},
"urlsite": {
"Value": "https://*.mydomain-staging.com"
}
}
}
All right. The bucketDeployment construct creates the assets. I think you can try propertyMatchers. IgnoreAssets currently only works for lambdas.
expect(stack).toMatchCdkSnapshot({
ignoreAssets: true,
propertyMatchers: {
Resources: {
BucketDeploymentAssetsCustomResource18D602EE: {
Properties: {
SourceBucketNames: expect.any(Array),
SourceObjectKeys: expect.any(Array),
}
},
//...
}
}
});
All right. The bucketDeployment construct creates the assets. I think you can try propertyMatchers. IgnoreAssets currently only works for lambdas.
expect(stack).toMatchCdkSnapshot({ ignoreAssets: true, propertyMatchers: { Resources: { BucketDeploymentAssetsCustomResource18D602EE: { Properties: { SourceBucketNames: expect.any(Array), SourceObjectKeys: expect.any(Array), } }, //... } } });
Unfortunately this excludes any other resource from the test. Is there a way to include everything but just fine tune some of the resources?
In case somebody stumbles here based on a google search, here's a workaround that works with vanilla aws-cdk-lib/assertions and can most likely be adapted for uses case with jest-cdk-snapshot:
import { Template } from 'aws-cdk-lib/assertions';
test('Snapshot', () => {
// SNIP
const template = Template.fromStack(stack);
/**
* The template has a lambda function resource like this, where the S3Key changes whenever the lambda function code changes or when building codebase with different OS:
* // SNIP
"ExampleLambdaCCAF212F": Object {
"DependsOn": Array [
"ExampleLambdaServiceRoleDefaultPolicy40713755",
"ExampleLambdaServiceRole598AA0D0",
],
"Properties": Object {
"Code": Object {
"S3Bucket": "cdk-foobar-assets-1234567890-eu-west-1",
"S3Key": "85a886236522b91357cf67203335e0662dd8de33034639086f260550c96f7aa6.zip",
},
"Handler": "index.handler",
* // SNIP
*/
// Find as limited set of lambda functions from template as possible:
const s = template.findResources('AWS::Lambda::Function', {
Properties: {
Handler: 'index.handler',
}
});
console.log(JSON.stringify(s, null, 2));
// Log the keys of the found resources, one of them should be ExampleLambdaCCAF212F
const keys = Object.keys(s);
console.log(keys);
// In this case only one lambda function should be found
expect(keys.length).toBe(1);
const key = keys[0];
// Verify the found lambda function resource key is the desired one:
// This here uses jest-extended toStartWith matcher
expect(key).toStartWith('ExampleLambda');
const json = template.toJSON();
// Finally, before performing the snapshot testing of the whole templte, replace the S3Key of the lambda function with a static value as we do not care about the hash value in this snapshot test
json.Resources[key].Properties.Code.S3Key = "REMOVED-BECAUSE-WE-ARE-NOT-INTERESTED-IN-LAMBDA-CODE-HASH-IN-THIS-TEST";
// This passes even if the lambda function code of ExampleLambdaCCAF212F changes
expect(json).toMatchSnapshot();
});