-
Notifications
You must be signed in to change notification settings - Fork 149
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
feat: Parameter store and secrets manager handling #36
feat: Parameter store and secrets manager handling #36
Conversation
* No complete tests yet, so I haven't commited it. (I also can't figure out how to write tests for this section. This is my first time programming node.js). * Added several new error areas with more details about which part was errored to make sure dev knows where the problem is...
* Updated README to show how to use the configure aws credentia;s workflow can give this workflow the AWS account ID
* You can now use an external secrets file (that must abide by a certain format, similar to the task definition's) * Updated README for external secrets file feature * A secrets file AND secrets inside of a task definition can be combined in usage.
* Accidentally copied and pasted incorrectly from gitpod workspace, so index.js is back * Renamed region-name to aws-region to be consistent with other aws github actions
@michaelhelmick Is this PR what you're looking for? It allows for base secrets from parameter store and secretsmanager in the task definition and a secondary, external secrets JSON file in which both can be combined. Also, do you mind answering this question: where is the executionRoleArn supposed to be? I'm just a beginner in knowing about AWS and even worse with JS since I've never used it before, but the newly created tests pass and the last part I need to know is the answer to that question. Thanks! |
DOC TODO (not for this repo)
|
@clareliguori Any thoughts? My JS isn't very good... so sorry for some weird programming. |
Hi @Andrew-Chen-Wang , thanks for taking the time to submit this! My understanding is we're trying to accomplish 2 things here:
For the second one (task def merging), I'd prefer if we built a generic merge functionality, vs. one specific to secrets, so that this action can accommodate more use cases (such as overriding CPU, mentioned in the original issue). For the first one, account IDs are not strictly sensitive, but it is a common practice to obscure them. If you'd prefer to keep it out of your public repository but want to add SSM parameters to your task definition, we have a couple options re: using this action:
Coupled with generic "merge" capability, your workflow might then look like this:
Would one of these options work for your case? Let me know if you have any questions re: the above or if you would like to take a stab at a more generic "merge" feature. |
element.valueFrom = `arn:aws:${valueFrom[0]}:${regionName}:${accountID}:${(valueFrom[0] == 'ssm') ? 'parameter' : 'secret'}${valueFrom[1]}` | ||
|
||
// Set executionRoleArn to use secrets section | ||
taskDefContents.executionRoleArn = `arn:aws:iam::${accountID}:role/ecsTaskExecutionRole` |
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.
FYI the execution role may not always have this name, it's valid to use a custom one.
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.
Huh the more you know... I think the generic merge might be necessary.
Thanks for taking a look at this @allisaurus! I was mostly scared about leaking an account ID. I've been reading around that it was a faux pas to let it into the wild. I'm definitely getting busier with college coming around, and my JS is still very... the skills are lacking. Regarding the full Arn, I looked up how to do the shorter one, but nothing really came up. If I'm not mistaken, the Name attribute vs. the valueFrom attribute have two separate purposes: Name belonging to the environment variable name on the system and valueFrom being the ARN in SSM or Secrets manager. Do you mind sharing an example of the newer version? Thanks! Lastly, for the generic merger functionality, I was thinking we could use the "with" part of GitHub actions. I don't really like piling up my GitHub secrets since those should truly be secrets whereas something as public as CPU core count doesn't really need to go in there. But, for sure, a generic merger functionality seems more favorable. I think the way Claire did it was pretty clean, though, and that might be the correct way to go. Then again, I haven't touched JS or this PR in awhile and school's coming up, so I'm not entirely sure if I can even get around to this. |
FWIW, I throw mine in AWS secrets manager and just paste the secret ARN as a valueFrom |
@Andrew-Chen-Wang you should be able to reference an SSM parameter by name in the
should also work as:
You may have to play with it (for example, I'm not sure if the preceding slash is needed), but that would eliminate the need to reveal the account number. re: this:
@michaelhelmick 's approach is what we normally see and what I would recommend; keep sensitive values out of the task def and instead reference their parameters (by name or ARN). |
Closing due to lack of activity. @Andrew-Chen-Wang feel free to reopen or resubmit if you'd like to make updates, or submit an issue if you have other questions about using this action. |
Hi @allisaurus getting slightly busy lately. I will re-open this when I have time. I also tried out the short format for all these ARNs. I added the slash at the beginning of valueFrom, but I don't know if it's necessary. executionRoleArn can also just be the ECS instance role's name. Thanks again! |
Issue #, if available:
Attempting to solve #20
Description of changes:
Disclaimer: I have barely used AWS as I'm a beginner, so I've got a some questions below... Anyways.
Added GitHub input for turning on handling parameter store and secretsmanager valueFrom. You can have a base set of secrets in the task definition (or only those) and an external JSON file for injecting secrets values without showing the AWS account ID (by using the output from configure AWS credential action).
But I'm wondering about the current implementation of "substituting the task definition with parameters/secrets"(this is also my first time with node JS... so I haven't really gotten the hang of writing the tests with the mock JSON as my initial shot at it with jest failed spectacularly).Is the arn format even ok? I omitted the account ID and the parameter path expected must start with a "/". I'm pretty sure it's fine to not begin with a slash in parameter store, so if the parameter does not begin with a slash, should I instead insert a ":"?Nevermind. Added the / at the beginning.Is it even bad if the arn is exposed in a public repository in the task definition? I'm just most concerned about an exposed account ID, if that's even dangerous to expose... I don't know, beginner, confused AWS person. Do you need the account ID? Some parts of the AWS docs have it, other parts don't (maybe I'm confusing regular parameters with public parameters for AMIs?).README now includes how to include the account ID.Not sure where the executionRoleArn is supposed to be.Also not sure if I should update the JSON minimum role in the README.rst... mostly because I have NO clue what is actually needed... I'mstrugglingsuccessful with ECS deployment myself here...By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.