Search code examples
typescriptaws-cdkaws-config

Object literal may only specify known properties, and 'allAwsRegions' does not exist in type 'IResolvable'


I am currently doing some work with the AWS-CDK and I am trying to create a Config Aggregator to aggregate the storage of all of my regions config logs. I am doing this with a region as the source instead of an account because I am not allowed/able to configure organizations. Here is the error I am currently receiving when trying to add props to the code below.

Object literal may only specify known properties, and 'allAwsRegions' does not exist in type 'IResolvable | (IResolvable | AccountAggregationSourceProperty)[]'.ts(2322)

Here is my code:

     const awsRegion = Aws.ACCOUNT_ID.toString()
      const awsAccountID = Aws.ACCOUNT_ID.toString()


const globalAggregatorAuth = newconfig.CfnAggregationAuthorization(this,'globalAggregatorAuth',{
        authorizedAwsRegion: awsRegion,
        authorizedAccountId: awsAccountID,
      } )
    const globalAggregator = new config.CfnConfigurationAggregator(this, 'globalAggregator', {
            configurationAggregatorName: 'globalAggregator',
            accountAggregationSources: { 
              accountIds: awsAccountID,
    
            }
        });

The error is above is currently coming when I try to use the prop accountIds and give it a value of "awsAccountID" which is assigned its value from the variable you see above. I have not experienced an issue such as this before and would greatly appreciate help!!!


Solution

  • As per the documentation

    accountIds  string[]    CfnConfigurationAggregator.AccountAggregationSourceProperty.AccountIds.
    

    In other words you need to pass in an array of strings like so:

    const globalAggregator = new config.CfnConfigurationAggregator(this, 'globalAggregator', {
        configurationAggregatorName: 'globalAggregator',
        accountAggregationSources: [{ 
            accountIds: [awsAccountID],   
        }]
    });