question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-fis): MapProperties generate empty CFN output

See original GitHub issue

I’m trying to generate a CfnExperimentTemplate with an CfnExperimentTemplate.ExperimentTemplateActionProperty and a CfnExperimentTemplate.ExperimentTemplateTargetProperty. I define it as follows:

const action: fis.CfnExperimentTemplate.ExperimentTemplateActionProperty = {
      actionId: 'aws:ec2:stop-instances',
      parameters: { startInstancesAfterDuration: 'PT1M' },
      targets: { Instances: 'myInstance'}
    }
const target: fis.CfnExperimentTemplate.ExperimentTemplateTargetProperty = {
      resourceType: 'aws:ec2:instance',
      resourceTags: { env: 'DEV' },
      selectionMode: 'COUNT(1)'
    }
const template = new fis.CfnExperimentTemplate(this,'fis-template', {
      description: 'My first Template',
      roleArn: role.roleArn,
      stopConditions: [
        { source: 'none' }
      ],
      tags: {},
      actions: {
        'TerminateInstances' : action
      },
      targets: {
        'myInstance': target
      }
    });

when doing a cdk synth this results in the following

Type: AWS::FIS::ExperimentTemplate
    Properties:
      description: My first Template
      roleArn:
        Fn::GetAtt:
          - fisrole33E76559
          - Arn
      stopConditions:
        - source: none
      tags: {}
      targets:
        myInstance:
          resourceTags: {}
          resourceType: aws:ec2:instance
          selectionMode: COUNT(1)
      actions:
        TerminateInstances:
          actionId: aws:ec2:stop-instances
          parameters: {}
          targets: {}

note the empty resourceTags in the targets as well as several other properties being empty (e.g. actions.TerminateInstance.targets)

What did you expect to happen?

The properties I define in CDK should all show up in CFN.

Environment

  • CDK CLI Version : 1.100.0
  • Framework Version: 1.100.0
  • Node.js Version: 14.16.1
  • OS : macOs Big Sur
  • Language (Version): TypeScript

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
PatMyroncommented, Oct 25, 2021

wrote a quick JSON schema for the structure of CloudFormation Resource Specifications and caught all the PropertyTypes missing either Properties or Documentation:

(click to expand)
    "AWS::SSM::PatchBaseline.PatchStringDate": {
      "PrimitiveType": "String"
    },
    "AWS::Transfer::User.SshPublicKey": {
      "PrimitiveType": "String"
    },
    "AWS::Transfer::Server.Protocol": {
      "PrimitiveType": "String"
    },
    
    "AWS::AppSync::GraphQLApi.AdditionalAuthenticationProviders": {
      "Type": "List",
      "Required": false,
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationproviders.html",
      "ItemType": "AdditionalAuthenticationProvider",
      "UpdateType": "Mutable"
    },
    "AWS::AppSync::GraphQLApi.Tags": {
      "Type": "List",
      "Required": false,
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-tags.html",
      "ItemType": "Tag",
      "UpdateType": "Mutable"
    },
    "AWS::CodeBuild::Project.FilterGroup": {
      "Type": "List",
      "Required": false,
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-filtergroup.html",
      "ItemType": "WebhookFilter",
      "UpdateType": "Mutable"
    },
    "AWS::CloudWatch::InsightRule.Tags": {
      "Type": "List",
      "Required": false,
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-insightrule-tags.html",
      "ItemType": "Tag",
      "UpdateType": "Mutable"
    },
    "AWS::Glue::SecurityConfiguration.S3Encryptions": {
      "Type": "List",
      "Required": false,
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-securityconfiguration-s3encryptions.html",
      "ItemType": "S3Encryption",
      "UpdateType": "Mutable"
    },
    "AWS::LakeFormation::DataLakeSettings.Admins": {
      "Type": "List",
      "Required": false,
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lakeformation-datalakesettings-admins.html",
      "ItemType": "DataLakePrincipal",
      "UpdateType": "Mutable"
    },
    
    "AWS::FIS::ExperimentTemplate.ExperimentTemplateActionItemParameterMap": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-fis-experimenttemplate-experimenttemplateactionitemparametermap.html"
    },
    "AWS::FIS::ExperimentTemplate.ExperimentTemplateActionItemTargetMap": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-fis-experimenttemplate-experimenttemplateactionitemtargetmap.html"
    },
    "AWS::FIS::ExperimentTemplate.TagMap": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-fis-experimenttemplate-tagmap.html"
    },
    "AWS::Macie::FindingsFilter.Criterion": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-macie-findingsfilter-criterion.html"
    },
    "AWS::MWAA::Environment.TagMap": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-mwaa-environment-tagmap.html"
    },
    "AWS::SageMaker::DataQualityJobDefinition.Environment": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-dataqualityjobdefinition-environment.html"
    },
    "AWS::SageMaker::ModelBiasJobDefinition.Environment": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-modelbiasjobdefinition-environment.html"
    },
    "AWS::SageMaker::ModelExplainabilityJobDefinition.Environment": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-modelexplainabilityjobdefinition-environment.html"
    },
    "AWS::SageMaker::ModelQualityJobDefinition.Environment": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-modelqualityjobdefinition-environment.html"
    },
    "AWS::SageMaker::MonitoringSchedule.Environment": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sagemaker-monitoringschedule-environment.html"
    },
    "AWS::StepFunctions::StateMachine.Definition": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachine-definition.html"
    },
    "AWS::S3::StorageLens.Encryption": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-storagelens-encryption.html"
    },

the property types with only documentation links and no property information are all CloudFormation Registry resource types and the rest all aren’t CloudFormation Registry resource types

the CloudFormation Registry resource schema conversion issue should be prioritized since types are migrating to that framework


JSON schema:
{
   "$schema":"http://json-schema.org/draft-07/schema#",
   "type":"object",
   "additionalProperties":false,
   "properties":{
      "ResourceSpecificationVersion":{
         "type":"string",
         "maxLength":7,
         "pattern":"^([0-9]+\\.){2}0$"
      },
      "ResourceTypes":{
         "type":"object",
         "propertyNames":{
            "pattern":"^(AWS|Alexa)(::.*){2}$"
         },
         "additionalProperties":{
            "type":"object",
            "additionalProperties":false,
            "properties":{
               "Documentation":{
                  "type":"string",
                  "pattern":"^https?:"
               },
               "Properties":{
                  "type":"object",
                  "additionalProperties":{
                     "type":"object",
                     "properties":{
                        "Documentation":{
                           "type":"string",
                           "pattern":"^https?:"
                        },
                        "UpdateType":{
                           "type":"string",
                           "enum":[
                              "Mutable",
                              "Immutable",
                              "Conditional"
                           ]
                        },
                        "Required":{
                           "type":"boolean"
                        }
                     },
                     "required":[
                        "Documentation",
                        "UpdateType",
                        "Required"
                     ]
                  }
               },
               "Attributes":{
                  "type":"object"
               },
               "AdditionalProperties":{
                  "type":"boolean"
               }
            },
            "required":[
               "Documentation"
            ]
         }
      },
      "PropertyTypes":{
         "type":"object",
         "propertyNames":{
            "pattern":"^((AWS|Alexa)(::.*){2}\\..*|Tag)$"
         },
         "additionalProperties":{
            "type":"object",
            "properties":{
               "Properties":{
                  "type":"object",
                  "additionalProperties":{
                     "type":"object",
                     "properties":{
                        "Documentation":{
                           "type":"string",
                           "pattern":"^https?:"
                        },
                        "UpdateType":{
                           "type":"string",
                           "enum":[
                              "Mutable",
                              "Immutable",
                              "Conditional"
                           ]
                        },
                        "Required":{
                           "type":"boolean"
                        }
                     },
                     "required":[
                        "Documentation",
                        "UpdateType",
                        "Required"
                     ]
                  }
               },
               "Documentation":{
                  "type":"string",
                  "pattern":"^https?:"
               }
            },
            "required":[
               "Documentation",
               "Properties"
            ]
         }
      }
   },
   "description":"Resource Specification JSON Schema",
   "required":[
      "ResourceSpecificationVersion",
      "ResourceTypes",
      "PropertyTypes"
   ]
}
1reaction
skinny85commented, May 4, 2021

Apologies @peterwoodworth , you were right.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Outputs - AWS CloudFormation
Return one or more values by defining outputs in the Outputs section of an AWS CloudFormation template.
Read more >
Property Handler cannot be empty - The following resource(s ...
Am trying to create lamda function using cloudformation. While creating stack am getting error like below. I have pasted my template below.
Read more >
With cfn-lint - Serverless Rules
If the template fulfills the requirements for all rules, cfn-lint will return an empty output. Otherwise, cfn-lint will output recommendations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found