Retrive CloudFront config

we have created three CF distributions “ETXXX1” and "ETXXX2"from different repo. And now i want add new config and behavior to existing CF “ETXXX1” from a different repo.

How should i retrieve existing CF config and add a new origin and behavior.

Use aws_cloudfront_distribution as datasource to fetch your existing CF and

data "aws_cloudfront_distribution" "test" {
 id = "EDFDVBD632BHDS5"

Then whichever resource you want to create for this specific resource, you can reference using data.aws_cloudfront_distribution.test.<attribute-ref>

Hi Tammay, thanks for responding. I tried below , but getting a compile error at data or property expected got

and also as per documentation it does not have attributes like origin, default_cache then how can we refer.

resource "aws_cloudfront_distribution" "s3_distribution" {
id= "ETXXXX"
enabled = True
data.aws_cloudfront_distribution.test.origin =

    domain_name              = aws_s3_bucket.b.bucket_regional_domain_name
    origin_access_control_id = [](
    origin_id                = local.s3_origin_id

Yeah, you can only use the attributes that’s listed in docs, hence origin doesn’t work.

Also, the data block is a separate section, you shouldn’t embed that inside the resource block.

I see that the only option if you still want to manage it using TF is, import the CF to your new state first, once that is done, add your new origin along with old one, so that TF wont destroy your older origin data.

But this is not a good idea since you will be managing the same resource across 2 state files, so changing at one side causes drift on another.

this the structure we are following

all global will be created first cf, route53, s3 etc and the multiregion in same repo
while creating cloudfront , i created origin for s3 so far its good. Now in multiregion i have created apigateway and now

want to create origin for api , i have get the existing config of cloudfront and then add the new origin. , which is

where i am facing challenges.