When we started with Pulumi, we start by using it ...
# general
m
When we started with Pulumi, we start by using it for Route53, so we have a project that manages the DNS records for the domain, i.e. example.com. This is convenient as you can see/update all the DNS from one file/project. Now we are creating another project to provision a Cloudfront site. The site needs to be attached to a sub-domain, i.e. foo.example.com. We thought it would be good if that project could attach the foo.example.com to Cloudfront. But then the Route53 project would not see this domain (and would delete it on running ` pulumi up). I suppose I could keep all DNS changes in the Route 53 project. So you would need to run both projects to attach foo.example.com to Cloudfront. Or is there another approach so the Cloudfront project can manage the foo.example.com yet Route53 also see this domain?
c
What about using stack references for this.
l
That, or create that specific DNS record in the CF project.
m
I think if I create the specific DNS in the CF project, then when I run the Route53 project, it would be deleted? So I’m thinking I can may do like this (in pseudo-code) , have the CF project create the DNS and export the CF resource
Copy code
/Cloudformation project creates cloudformation url
const myDistribution = new aws.cloudfront.Distribution
//example12345.cloudfront.net.
//export this as a stack variable 
pulumi.export("myDistribution", )


//point cloudfront to <http://example.com|example.com>
const cnameForCloudfront = new aws.route53.Record(
	"myCname",
	{
		name: "foo",
		records: [{myDistribution.domainName}],
		ttl: 1800,
		type: "CNAME",
		zoneId: "Z1MS401EDN11234",
	}	
);
then in the Route53 project, it will define the same DNS record by stack reference to the CF distribution
Copy code
//In the Route53 project 
// cloudfront = new Pulumi.StackReference(`the-cloudfront-stack`))
//...other sub-domains are defined...

//point <http://foo.example.com|foo.example.com> to Cloudfront
const cnameForCloudfront = new aws.route53.Record(
	"myCname",
	{
		name: "foo",
		records: [{variable referring to other stack,i.e. c}],
		ttl: 1800,
		type: "CNAME",
		zoneId: "Z1MS401EDN11234",
	}	
);
This way it’s defined in both. If you look at the Route53, you’ll see all DNS records (which is convenient) and see it relates to the CF stack…if you are just looking at the CF project, you’ll see the specific dns, i.e. foo.example.com that the CF distribution points to. Does that sound like a reasonable approach?