Not sure if this fits here, or in the general help...
# seed
m
Not sure if this fits here, or in the general help section, and this is a bit tricky, I believe. What I am trying to do: Set up custom domains for both a dev and prod environment. I am using the build structure from the guide, and my react site is set up through the ReactStaticSite stack. My current set up : AWS Console: • root account <- This is where I have my domain set up in Route 53 ◦ mathewgries.com • AWS Organization account for both dev and prod ◦ able to successfully deploy to dev Organization through seed on git push ◦ I set up a Hosted zone in the dev Org, and added it to the root accounts domain set up. Have not deployed yet, but I think this is set up correctly. Questions I have: • Can I point my prod build to use the hosted zone in my root account, or would I need to do the same set up in my prod Organization that I did in my dev Account • I did see something about pointing to Hosted zones in the sst docs. Thinking that is how to do the former in the above point, but not seeing any detail on exactly how to actually implement this beyond an import. How does the import access the hosted zone from my root account? This might be a good start. I will probably have more questions from any responses. Thanks in advance
aww, may have figured this out. Not sure yet. Will update
I think I may have figured this out. What I would like to know is the construct of the customDomain object with multiple environments. I would guess it would be this, but not seeing anything stating what it it should be. Each property for each env just labled with the stage name?
Something else that has been confusing me with these constructs. The second parameter in these stack methods. What exactly is this for, and what is the best way to utilize this
Copy code
hostedZone: HostedZone.fromHostedZoneAttributes(this, "MyZone" <-- This gusy
this.api = new sst.Api(this, “Api” <-- And this guy Is this customizable, and how is it used behind the scenes. What should we be putting as a value here, and where doe it get used in the deployments?
For instance, with the sst.Table stack, I can see this value being appended to the end of the table name, this.table = new sst.Table(this, “MathewGriesDotCom”, dev-mathew-gries-dotcom-MathewGriesDotCom part of this seems redundant, but I can see the use here, if you have multiple tables, so I would assuming this would be to identify the stack/resource if you have have multiple resources of the same type under one app?
So, AWS docs are super confusing on top of the fact I don’t understand DNS in the slightest. Pretty sure I’m gonna be tackling this for the next week…
c
Lots of questions in here 🙂 To answer your last question first:
_this_.api = new sst.Api(_this_, "Api"
<- this guy is the logical ID for the resource. CDK uses this plus a random hash to uniquely identify resources. So if you modify the declaration here then CDK will know which resource to update in the cloud. You're right that CDK appends resources with logical id of its parents and it can be redundant depending on how you name it. We use names that describe what the resource is (without context) and then when CDK appends the parent resource's logical id you have a descriptive name. For example: MyFirstStack -> SharedInf -> UsersTable So the logical ID you will see in cloudformation will be something like: MyFirstStack/SharedInf/UsersTable Now to answer your first question:
Can I point my prod build to use the hosted zone in my root account, or would I need to do the same set up in my prod Organization that I did in my dev Account
You should do the same setup in prod that you did in dev account. You probably could point prod to root (I can imagine there is a way to do this) but this goes against best practice. Ideally, you should not have anything in your root account and use that for billing and then use your prod account for prod related resources. So doing what you did in dev is probably the easiest, most secure and most scalable approach. For the second question you could also do something like this:
Copy code
route53.HostedZone.fromLookup(this, 'MyZone', { domainName: `www.${environment}.<http://mathewgries.com|mathewgries.com>` })
f
@Chad (cysense) is 100% on point with the answers above. We need to explain the id part better in the doc. Since it’s used as Logical IDs in CloudFormation template, changing the id will cause recreating (removing exist and creating new) the resource. So in most situations, you don’t want to change the id of the construct.
As for the custom domain, you can configure it based of the
stage
you are deploying to. You can access the stage like this:
Copy code
this.node.root.stage;
Or in TypeScript:
Copy code
const app = scope.node.root as <http://sst.App|sst.App>;
app.stage
Let me know if you have questions.
m
@Chad (cysense) and @Frank Thanks for responding and confirming how I thought that namespace was used. I’ve said it before, but what you guys are doing with SST is awesome, and the level of effort you put in to the guide, and documentation is amazing. The domain was set up on the root account awhile before I set the organizations up, which is why it is there. I agree it should probably be for billing, but it’s just me using this set up at the moment, and figured a centralized place for the domain would be best. My biggest issue now is access permissions, and trying to figure that out. My dev organization user is being denied usage of the domain. Im wiping out some entries on the organization and trying again with your suggestions. Thanks!
At this point, I am going with the defaults. Will have to look deeper into this, and figure it out along the way