private getCloudFrontPrefixList()

in lib/ide-services-resources.ts [616:647]


  private getCloudFrontPrefixList(): string {
    // Create a custom resource to fetch the CloudFront managed prefix list
    const describePrefixLists = new cr.AwsCustomResource(this, 'DescribePrefixLists', {
      onUpdate: {
        // The AWS service and API call we want to make
        service: 'EC2',
        action: 'describeManagedPrefixLists',
        // Parameters for the API call
        parameters: {
          Filters: [
            {
              Name: 'owner-id',
              Values: ['AWS']
            },
            {
              Name: 'prefix-list-name',
              Values: ['com.amazonaws.global.cloudfront.origin-facing']
            }
          ]
        },
        // What to extract from the response
        physicalResourceId: cr.PhysicalResourceId.of('CloudFrontPrefixList'),
      },
      // Policy that allows the custom resource to call the API
      policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
        resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
      }),
    });

    // Extract the prefix list ID from the custom resource result
    return describePrefixLists.getResponseField('PrefixLists.0.PrefixListId');
  }