Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDK Additional Information #47

Closed
judemanutd opened this issue Oct 20, 2022 · 5 comments
Closed

CDK Additional Information #47

judemanutd opened this issue Oct 20, 2022 · 5 comments
Labels
documentation Changes only affect the documentation enhancement New feature or request

Comments

@judemanutd
Copy link

Hey @sladg great library and this isn't really an issue as such, it's just more of an information gathering question.

I ran the commands that were mentioned and the app was definitely deployed but I'm not really familiar with CDK and that's kind of where my question lies.

Initially, I ran into an issue with the deploy command not being able to find the environment variables so that led me to installing cdk and running cdk bootstrap and that solved the issue as I was able to point it to the correct profile, account and region.

So my question is, is there a way I can configure AWS related attributes like the name of the Cloudfront resource or associating a domain with the Cloudfront distribution. This might be a CDK related question but I just wanted to drop it here to confirm that. I can indeed see CDK related config in the cdk.out folder and my guess is that editing the data there should help with this.

@sladg
Copy link
Owner

sladg commented Oct 21, 2022

Hey @judemanutd!

Soo, to answer first part (and I will probably update the README a bit to be more CDK-beginner friendly), you can use --bootstrap flag with deploy command which will make it easier for first-time deployment without bootstrapped env.

Secondly, in terms of changing resource names, etc. all the names are derived from StackName which you can specify as you see fit, in case you need more granular access, I would suggest copying my CDK code and modifying it. I don't expect 90% of people to need this so I would rather keep it simple out-of-the-box than provide excessive amount of configuration.

In case something needs to be modified, I have included some output values in Cloudformation stack, those can be accessed and further modified outside of the CDK script.
See: https://stackoverflow.com/questions/41628487/getting-outputs-from-aws-cloudformation-describe-stacks

Lastly, in terms of domains. I'm actually considering putting this feature into place, ideas are definitely appreciated on how this would be used / what would be ideal setup for you.

Currently, I would suggest creating the DNS manually once the stack is created :) this worked best for me in past (error mitigation as this part of infrastructure is not part of git). Alternatively, AWS-CLI is here to help (see: https://stackoverflow.com/questions/68493338/adding-domains-to-aws-cloudfront-distribution-via-api) or SDK/CDK.

My take at this point would probably be to create secondary CDK stack just for the domain, make it fetch Cloudfront distro ID from other stack and create A & AAAA records in your hosted zone.

@judemanutd
Copy link
Author

Thanks, was contemplating forking the library as well and customizing it on my end. Looks like I'll need some brushing up on the CDK front.

On the domain front, things could get a bit complicated depending on how you want to go about it. I'm seeing 2 possible situations here

  1. The user already has the domain setup and is likely managing the resource outside of AWS
  2. The user has nothing setup and wants AWS to handle it

In case 1, I think it's simply a matter of accepting the domains as an environment variable and associating them with the Cloudfront distribution which I think can be done within the same stack.

In case 2, yeah I think creating a new stack would make managing it much simpler.

P.S. out of curiosity, are you looking to add additional configurations to this library at some point in the roadmap? Things like SSL certificate generation, customizing various attributes, etc. I only ask because this seems like quite an interesting avenue and I would love to contribute to this if you do plan on having that in the roadmap at some point.

@sladg
Copy link
Owner

sladg commented Oct 23, 2022

FYI, I have added configuration for lambda's memory and timeout. Will look into DNS next.

@sladg sladg added documentation Changes only affect the documentation enhancement New feature or request labels Oct 23, 2022
@judemanutd
Copy link
Author

Hey @sladg feel free to close this issue if you need to.

@sladg
Copy link
Owner

sladg commented Oct 30, 2022

As of version 3.18.0 you can now pass additional parameters to deploy command and it will handle DNS, aliases and certificate creation :)

--hostedZone <domainName>    Hosted zone domain name to be used for creating DNS records (example: example.com).
--domainNamePrefix <prefix>  Prefix for creating DNS records, if left undefined, hostedZone will be used (example: app).

@sladg sladg closed this as completed Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Changes only affect the documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants