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

support cloudfront for gateway and static unit #27

Merged
merged 3 commits into from
Jan 6, 2023
Merged

Conversation

jhsinger-klotho
Copy link
Contributor

• Does any part of it require special attention?
• Does it relate to or fix any issue? closes #349

adds cdnId to both gateway and static unit config. This allows us to have logic in the compiler to understand when and how many cloudfront distributions we need with respective origins.

Then the remainder of the logic is handled in deploylib for now until we have a better dependency tree for our aws resources.

We conditionally add the files for static website and cloudfront since we know if we are creating any and just pass in cloudlibs object to avoid more stuff being stuck in compiled

Standard checks

  • Unit tests: Any special considerations? added some for cloudfront generation
  • Docs: Do we need to update any docs, internal or public? will update before pushing
  • Backwards compatibility: Will this break existing apps? If so, what would be the extra work required to keep them working? static units will no longer use pulumi params and must explicitly set the cdnId to be backed by cloudfront. We also no longer create a publicly accessible bucket ever.

// Create an S3 bucket

const bucketArgs: aws.s3.BucketArgs = {}

if (indexDocument != '' && !params.cloudFrontEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this !params.cloudFrontEnabled still need to exist? The cloudfrontenabled code was moved out but i'm assuming the following code still shouldn't be run if it is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah youre right, we should still be checking if its enabled here. will need to update

for _, res := range result.Resources() {
key := res.Key()
switch res.(type) {
case *core.Gateway:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i think aside from the a.Config.GetExposed(key.Name) and a.Config.GetStaticUnit(key.Name) the rest of the logic is the same so the switch could just set that and the rest of the logic moved out and de-duped


for name, keys := range cloudfrontMap {
cf := resources.CreateCloudfrontDistribution(keys)
cf.Id = a.Config.AppName + "-" + name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like the name value is the same across the app. Is there only a single distribution per app deployment? If i have 1 static unit and 1 gateway, they would be the same cf.Id, is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name is determined by config. The user has to provide the Id for the CDN. We can look at autogenerating it but my issue with that was that they could name the gateway and static unit the same thing and then we would generate the same name.

I opted for it to be explicit, but we can opt out of that if we think thats best

},
},
{
name: "static unit and gw test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, given there is a test for it, i assume the answer to my previous comment is probably yes intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah see comment above, lets have a chat about this because this is purely how we want user experience to be and thats the main part i wanted some feedback on

@ewucc
Copy link
Contributor

ewucc commented Jan 5, 2023

no blocking comments.

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

Package Line Rate Health
github.com/klothoplatform/klotho/pkg/analytics 2%
github.com/klothoplatform/klotho/pkg/annotation 24%
github.com/klothoplatform/klotho/pkg/core 21%
github.com/klothoplatform/klotho/pkg/env_var 82%
github.com/klothoplatform/klotho/pkg/exec_unit 41%
github.com/klothoplatform/klotho/pkg/infra/kubernetes 58%
github.com/klothoplatform/klotho/pkg/infra/kubernetes/helm 52%
github.com/klothoplatform/klotho/pkg/input 63%
github.com/klothoplatform/klotho/pkg/lang 37%
github.com/klothoplatform/klotho/pkg/lang/dockerfile 0%
github.com/klothoplatform/klotho/pkg/lang/golang 9%
github.com/klothoplatform/klotho/pkg/lang/javascript 46%
github.com/klothoplatform/klotho/pkg/lang/python 60%
github.com/klothoplatform/klotho/pkg/lang/yaml 0%
github.com/klothoplatform/klotho/pkg/logging 7%
github.com/klothoplatform/klotho/pkg/multierr 95%
github.com/klothoplatform/klotho/pkg/provider/aws 60%
github.com/klothoplatform/klotho/pkg/runtime 75%
github.com/klothoplatform/klotho/pkg/static_unit 22%
github.com/klothoplatform/klotho/pkg/validation 73%
Summary 42% (3562 / 8542)

@jhsinger-klotho jhsinger-klotho merged commit 8b294c1 into main Jan 6, 2023
@jhsinger-klotho jhsinger-klotho deleted the cloudfront branch January 6, 2023 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants