Skip to content

Commit 08ca2aa

Browse files
committed
initial release
0 parents  commit 08ca2aa

File tree

14 files changed

+42884
-0
lines changed

14 files changed

+42884
-0
lines changed

.eslintrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
'env': {
3+
'browser': true,
4+
'es2021': true,
5+
'jest': true,
6+
},
7+
'extends': [
8+
'google',
9+
],
10+
'parserOptions': {
11+
'ecmaVersion': 12,
12+
},
13+
'plugins': [
14+
'no-floating-promise',
15+
],
16+
'root': true,
17+
'rules': {
18+
'dot-notation': ['error', {'allowKeywords': true }],
19+
'max-len': 'off',
20+
'new-cap': 'warn',
21+
'no-floating-promise/no-floating-promise': 'error',
22+
'no-reserved-keys': 'off',
23+
'no-unused-vars': 'warn',
24+
'no-wrap-func': 'off',
25+
'require-jsdoc': 'warn',
26+
'space-after-keywords': 'off',
27+
'space-return-throw-case': 'off',
28+
'spaced-line-comment': 'off',
29+
},
30+
};

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
coverage/
3+
4+
.nvmrc
5+
**/*.log
6+
.vscode/

.jest.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// jest.config.js
2+
// Sync object
3+
/** @type {import('@jest/types').Config.InitialOptions} */
4+
const config = {
5+
bail: 2,
6+
clearMocks: true,
7+
collectCoverage: true,
8+
verbose: true,
9+
};
10+
11+
module.exports = config;

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contributing Guidelines
2+
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4+
documentation, we greatly value feedback and contributions from our community.
5+
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7+
information to effectively respond to your bug report or contribution.
8+
9+
10+
## Reporting Bugs/Feature Requests
11+
12+
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13+
14+
When filing an issue, please check [existing open](https://github.com/scribd/amazon-servicediscovery-service/issues), or [recently closed](https://github.com/scribd/amazon-servicediscovery-service/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
15+
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16+
17+
* A reproducible test case or series of steps
18+
* The version of our code being used
19+
* Any modifications you've made relevant to the bug
20+
* Anything unusual about your environment or deployment
21+
22+
23+
## Contributing via Pull Requests
24+
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25+
26+
1. You are working against the latest source on the *master* branch.
27+
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28+
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29+
30+
To send us a pull request, please:
31+
32+
1. Fork the repository.
33+
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34+
3. Ensure local tests pass.
35+
4. Commit to your fork using clear commit messages.
36+
5. Send us a pull request, answering any default questions in the pull request interface.
37+
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38+
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40+
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41+
42+
43+
## Finding contributions to work on
44+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/scribd/amazon-servicediscovery-service/labels/help%20wanted) issues is a great place to start.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Scribd, Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
## Amazon ServiceDiscovery Service Action for GitHub Actions
2+
3+
Creates an Amazon ServiceDiscovery Service
4+
5+
**Table of Contents**
6+
7+
<!-- toc -->
8+
9+
- [Amazon ServiceDiscovery Service Action for GitHub Actions](#amazon-servicediscovery-service-action-for-github-actions)
10+
- [Usage](#usage)
11+
- [Service Creation](#service-creation)
12+
- [Service Deletion](#service-deletion)
13+
- [Credentials and Region](#credentials-and-region)
14+
- [Permissions](#permissions)
15+
- [Troubleshooting](#troubleshooting)
16+
17+
<!-- tocstop -->
18+
19+
## Usage
20+
21+
### Service Creation
22+
23+
Create a ServiceDiscovery Service. At the minimum, supply `name`, and `dns-config` with an entry for `NamespaceId`.
24+
25+
parameter | description | default
26+
-----------------------|---------------------------------------------|----------
27+
`name` | The name that you want to assign to the service. |
28+
`namespace-id` | The ID of the namespace that you want to use to create the service. The namespace ID must be specified, but it can be specified either here or in the DnsConfig object. |
29+
30+
`description` | A description for the service. | `undefined`
31+
`dns-config` | A complex type that contains information about the Amazon Route 53 records that you want Cloud Map to create when you register an instance. | {}
32+
`health-check-config` | Public DNS and HTTP namespaces only. A complex type that contains settings for an optional Route 53 health check. If you specify settings for a health check, Cloud Map associates the health check with all the Route 53 DNS records that you specify in DnsConfig. | {}
33+
`health-check-custom-config` | A complex type that contains information about an optional custom health check. | {}
34+
`tags` | The tags to add to the service. Each Tag consists of a key and a value that you define(`[{Key: my-key, Value: my-value}]`). | []
35+
`type` | If present, specifies that the service instances are only discoverable using the DiscoverInstances API operation. No DNS records is registered for the service instances. The only valid value is HTTP. | `HTTP_DNS`
36+
37+
38+
```yaml
39+
- name: ServiceDiscovery Service
40+
id: create-servicediscovery-service
41+
uses: scribd/amazon-servicediscovery-service@master
42+
with:
43+
name: my-service
44+
dns-config: |
45+
{
46+
"NamespaceId": "ns-namespacename",
47+
"RoutingPolicy": "MULTIVALUE",
48+
"DnsRecords": [
49+
{
50+
"Type": "SRV",
51+
"TTL": 10
52+
}
53+
]
54+
}
55+
tags: |
56+
[
57+
{
58+
"Key": "tags-must",
59+
"Value": "be-passed-in-as-a-json-string"
60+
},
61+
{
62+
"Key": "this-is-because",
63+
"Value": "GitHub Actions translates these values into Environment Variables"
64+
}
65+
]
66+
```
67+
68+
### Service Deletion
69+
70+
The only value necessary to delete a service is the ID of the service. You can also specify the other inputs, but they will be ignored.
71+
72+
Note: This command will fail if there are still instances registered to the service.
73+
74+
```yaml
75+
- name: Delete ServiceDiscovery Service
76+
uses: scribd/amazon-servicediscovery-service@master
77+
with:
78+
action: delete
79+
id: ${{ steps.create-servicediscovery-service.outputs.id }}
80+
```
81+
82+
See [action.yml](action.yml) for the full documentation for this action's inputs and outputs.
83+
84+
85+
## Credentials and Region
86+
87+
This action relies on the [default behavior of the AWS SDK for Javascript](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html) to determine AWS credentials and region.
88+
Use [the `aws-actions/configure-aws-credentials` action](https://github.com/aws-actions/configure-aws-credentials) to configure the GitHub Actions environment with environment variables containing AWS credentials and your desired region.
89+
90+
We recommend following [Amazon IAM best practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) for the AWS credentials used in GitHub Actions workflows, including:
91+
* Do not store credentials in your repository's code. You may use [GitHub Actions secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) to store credentials and redact credentials from GitHub Actions workflow logs.
92+
* [Create an individual IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#create-iam-users) with an access key for use in GitHub Actions workflows, preferably one per repository. Do not use the AWS account root user access key.
93+
* [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) to the credentials used in GitHub Actions workflows. Grant only the permissions required to perform the actions in your GitHub Actions workflows. See the Permissions section below for the permissions required by this action.
94+
* [Rotate the credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#rotate-credentials) used in GitHub Actions workflows regularly.
95+
* [Monitor the activity](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#keep-a-log) of the credentials used in GitHub Actions workflows.
96+
97+
## Permissions
98+
99+
This action requires the following minimum set of permissions:
100+
101+
```json
102+
{
103+
"Version":"2012-10-17",
104+
"Statement":[
105+
{
106+
"Sid":"DeployService",
107+
"Effect":"Allow",
108+
"Action":[
109+
"servicediscovery:ListServices",
110+
"servicediscovery:CreateService",
111+
"servicediscvoery:DeleteService",
112+
"servicediscovery:TagResource"
113+
],
114+
"Resource":[
115+
"arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-abc123"
116+
]
117+
}
118+
]
119+
}
120+
```
121+
122+
123+
## Troubleshooting
124+
125+
To see the debug logs, create a secret named `ACTIONS_STEP_DEBUG` with value `true` in your repository.
126+
127+
To run this action from your workstation, you have to take into account the following bug: BASH doesn't think dashes are valid in environment variables, but Node does. You should therefore supply your environment variables with the `env` command.
128+
129+
Please include output from the following commands when submitting issues, it'll help greatly! Don't forget to redact any sensitive data from your submission.
130+
131+
See this example:
132+
133+
```bash
134+
❯ env "ACTIONS_STEP_DEBUG=true" "GITHUB_WORKSPACE=$(pwd)" 'AWS_REGION=us-east-1' 'INPUT_DNS-CONFIG={"NamespaceId": "ns-abc123", "RoutingPolicy": "MULTIVALUE", "DnsRecords":[{"Type": "SRV","TTL": 10}]}' "INPUT_NAME=my-service" 'INPUT_TAGS=[{"Key": "hello", "Value": "world"}]' node index.js
135+
```

0 commit comments

Comments
 (0)