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
Minor improvements to voting-app and webserver #5
Conversation
lindydonna
commented
Dec 15, 2017
- Simplified code in voting-app and added comments on what each part is doing
- Added 2 other versions of webserver for each stage of the quickstart (simple, add component, add availability zones)
- Fixed tsconfig to target only Node libraries (fixes part of https://github.com/pulumi/home/issues/88)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor comments.
"pulumi": "*" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^8.0.26" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor - but this can be a devDependencies
"strictNullChecks": true | ||
}, | ||
"files": [ | ||
"index.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we should include webserver.ts
here too I think. I believe this won't cause problems for most tools - but may as well add it.
}); | ||
|
||
server.publicDns.then(dns => console.log(`Server URL: http://${dns}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export let
here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Especially if we can somehow avoid needing to explain http://undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I need to explain http://undefined
later, because of the availability zone example and async. Full quickstart flow is here: https://github.com/pulumi/docs/blob/master/quickstart/aws.md or https://docs.pulumi.com/quickstart/aws.html
That said, I should certainly introduce export
right away, because it's an awesome feature.
@@ -0,0 +1,59 @@ | |||
{ | |||
// See https://go.microsoft.com/fwlink/?LinkId=733558 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eek, does VS Code really emit invalid JSON? 😳
Can we add .vscode
to the .gitignore
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional, so that people can build each project easily in vscode. If you'd prefer I remove it, I can.
Comments in JSON are technically not valid, but many JSON parsers accept them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove it. The pedant in me just cant stand to have illegal JSON in our repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the comments, are you ok with the file being there? It is actually useful for people who use VSCode, as it sets up build tasks for each project.
@@ -4,36 +4,41 @@ import * as cloud from "@pulumi/cloud"; | |||
|
|||
// To simplify this example, we have defined the password directly in code | |||
// In a real app, would add the secret via `pulumi config secret <key> <value>` and | |||
// access via config APIs | |||
// access via pulumi.Config APIs | |||
let redisPassword = "SECRETPASSWORD"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely would love to see this as a secret config variable. Else, it'll make people think we don't take security seriously, or that our product doesn't have the features required ... which it does!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed! I'll fix this when I start the bigger doc overhaul.
Ideally, I would change it so you add the secret in a later step, to simplify the flow. The problem is that this sample takes 20 minutes to deploy. If I change an environment variable in the docker container, what needs to be rebuilt?
import * as webserver from "./webserver"; // use the new custom component | ||
|
||
let webInstance = webserver.createInstance("web-server-www", "t2.micro"); | ||
let appInstance = webserver.createInstance("web-server-app", "t2.nano"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're in here, I have to admit ... at some point this changed from appInstance being a "large" to just being a "nano" ... every time I demo this, I have this inner feeling of awkwardness, because the app server is almost always beefier than the thing just serving up simple HTML. I wonder if we should change to even maybe a non-t2
instance size, something more "memory" optimized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but this sample is used in the quickstart and I wouldn't want to suggest people provision larger VMs that they don't use. Maybe m1.small? https://www.ec2instances.info/?selected=m1.small
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with @lindydonna, I think if this is something in the quickstart we should err on the side of small instances (and add appropriate warnings that this will deploy real resources which cost real money, in your account).
For the similar example in our examples
folder for tests, may make sense to use a larger size here for demoing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine keeping them small, but we should at least reverse the sizes... this really bugs me more than it should 😄
tags: { "Name": name }, // use the `name` parameter | ||
instanceType: size, // use function argument for size | ||
securityGroups: [ group.name ], // reference the group object above | ||
ami: aws.ec2.getLinuxAMI(size), // call built-in function (can also be custom) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider changing this to an AMI query instead of our own homegrown getLinuxAMI
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually had the AMI query and I changed it back, to simplify the example. I'm going to simplify even further and remove the userData
until a later step.
Also I need to change this back to JavaScript.
}); | ||
|
||
server.publicDns.then(dns => console.log(`Server URL: http://${dns}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Especially if we can somehow avoid needing to explain http://undefined
.
Talking to Luke more, I think the Availability Zone example is not worth using in its current form, since it means we can't use |
I'm going to merge as-is so that I can update the docs ASAP with a link to the examples for a customer. I filed #6 to track the code improvements. |
Minor improvements to voting-app and webserver