2

我目前正在使用 AWS-CDK 做一些工作,并且我正在尝试创建一个配置聚合器来聚合我所有区域配置日志的存储。我将区域作为源而不是帐户来执行此操作,因为我不允许/无法配置组织。这是我在尝试将道具添加到下面的代码时当前收到的错误。

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

这是我的代码:

     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,
    
            }
        });

当我尝试使用道具 accountIds 并给它一个“awsAccountID”值时,上面的错误当前正在出现,该值是从您在上面看到的变量中分配的值。我以前没有遇到过这样的问题,非常感谢帮助!!!

4

1 回答 1

0

根据文档

accountIds  string[]    CfnConfigurationAggregator.AccountAggregationSourceProperty.AccountIds.

换句话说,您需要传入一个字符串数组,如下所示:

const globalAggregator = new config.CfnConfigurationAggregator(this, 'globalAggregator', {
    configurationAggregatorName: 'globalAggregator',
    accountAggregationSources: [{ 
        accountIds: [awsAccountID],   
    }]
});
于 2020-11-08T16:16:27.737 回答