Skip to content

Commit

Permalink
chore: Add markdown linting checks (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
niallthomson authored Aug 12, 2024
1 parent 3bef664 commit 55842c7
Show file tree
Hide file tree
Showing 63 changed files with 155 additions and 340 deletions.
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": true,
"MD013": false,
"MD014": false,
"MD033": false,
"customRules": ["mdlint/aws-arn-rule.js"]
}
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ repos:
hooks:
- id: markdown-link-check
args: [-q, -c, link-check-config.json]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint
files: ^website/docs
args: [-r, mdlint/aws-arn-rule.js]
2 changes: 1 addition & 1 deletion docs/authoring_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ When creating your content you will want to test the commands you specify agains
Many of the convenience scripts we'll use will make calls to AWS APIs so will need to be able to authenticate. Getting AWS credentials in to a container in a portable way can be a challenge, and there are several options available:

1. Set `ASSUME_ROLE` environment variable in the terminal where you run the `make` commands to the ARN of an IAM role that you can assume with your current credentials. This will use the STS service to generate temporary credentials that will be injected in to the container. Example: `export ASSUME_ROLE='arn:aws:iam::123456789012:role/my-role'`
1. Set `ASSUME_ROLE` environment variable in the terminal where you run the `make` commands to the ARN of an IAM role that you can assume with your current credentials. This will use the STS service to generate temporary credentials that will be injected in to the container. Example: `export ASSUME_ROLE='arn:aws:iam::1234567890:role/my-role'`
1. Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables in the terminal where you run the `make` commands. It is recommended that these credentials be temporary. These variables will be injected in to the container.
1. If you are developing on an EC2 instance which has an instance profile that provides the necessary IAM permissions then no action is needed as the container will automatically assume the role of the EC2 on which you're authoring your content.

Expand Down
34 changes: 34 additions & 0 deletions mdlint/aws-arn-rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const awsAccountId = "1234567890";

module.exports = {
names: ["AWS-ARN-RULE"],
description: "Check if AWS ARNs use the correct sample account ID",
tags: ["aws", "arn"],
function: function aws_arn_rule(params, onError) {
const arnRegex = /arn:aws:([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)?:([0-9]+):/;

params.tokens.filter(function filterToken(token) {
let matches;

if (["paragraph_open"].indexOf(token.type) > -1) {
const paragraph = token.line.replace(/\r?\n|\r/g, "");
matches = paragraph.match(arnRegex);
}

if (["fence"].indexOf(token.type) > -1) {
const paragraph = token.content.replace(/\r?\n|\r/g, "");
matches = paragraph.match(arnRegex);
}

if (matches) {
const accountId = matches[3];
if (accountId !== awsAccountId) {
onError({
lineNumber: token.lineNumber,
detail: `AWS ARN account ID "${accountId}" does not match expected account ID "${awsAccountId}"`,
});
}
}
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace "ui" deleted

We will then need to create a customization for each application:

```
```text
.
|-- app-of-apps
| |-- ...
Expand Down Expand Up @@ -66,7 +66,7 @@ $ cp -R ~/environment/eks-workshop/modules/automation/gitops/argocd/apps-kustomi

Your final Git directory should now look like this. You can validate it by running `tree ~/environment/argocd`:

```
```text
|-- app-of-apps
| |-- Chart.yaml
| |-- templates
Expand Down
4 changes: 2 additions & 2 deletions website/docs/automation/gitops/argocd/app-of-apps/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We can leverage [Argo CD App of Apps pattern](https://argo-cd.readthedocs.io/en/

We reference [EKS Workshop Git repository](https://github.com/aws-samples/eks-workshop-v2/tree/main/manifests/base-application) as a Git repository with `base` manifests for your Kubernetes resources. This repository will contain an initial resource state for each application.

```
```text
.
|-- manifests
| |-- assets
Expand All @@ -28,7 +28,7 @@ We reference [EKS Workshop Git repository](https://github.com/aws-samples/eks-wo
This example shows how to use Helm to create a configuration for a particular, for example DEV, environment.
A typical layout of a Git repository could be:

```
```text
.
|-- app-of-apps
| |-- ...
Expand Down
2 changes: 1 addition & 1 deletion website/docs/automation/gitops/argocd/app-of-apps/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $ argocd app delete apps --cascade -y

We create templates for set of ArgoCD applications using DRY approach in Helm charts:

```
```text
.
|-- app-of-apps
| |-- Chart.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ cp -R ~/environment/eks-workshop/base-application/ui/* ~/environment/argocd/ap

Your Git directory should now look something like this which you can validate by running `tree ~/environment/argocd`:

```
```text
.
└── apps
├── configMap.yaml
Expand Down
10 changes: 5 additions & 5 deletions website/docs/automation/gitops/flux/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $ git -C ~/environment/retail-store-sample-codecommit push --set-upstream origin

You can navigate to `CodePipeline` in AWS Console and explore `eks-workshop-retail-store-sample` pipeline:

https://console.aws.amazon.com/codesuite/codepipeline/pipelines/eks-workshop-retail-store-sample/view
<ConsoleButton url="https://console.aws.amazon.com/codesuite/codepipeline/pipelines/eks-workshop-retail-store-sample/view" service="codepipeline" label="Open CodePipeline console"/>

It should look something like this:

Expand Down Expand Up @@ -99,19 +99,19 @@ $ flux reconcile kustomization apps --with-source

We need to deploy custom resource definitions (ImageRepository, ImagePolicy, ImageUpdateAutomation) for Flux to enable monitoring of new container images in ECR and automated deployment using GitOps.

1. ImageRepository:
An `ImageRepository`:

```file
manifests/modules/automation/gitops/flux/imagerepository.yaml
```

2. ImagePolicy:
An `ImagePolicy`:

```file
manifests/modules/automation/gitops/flux/imagepolicy.yaml
```

3. ImageUpdateAutomation:
An `ImageUpdateAutomation`:

```file
manifests/modules/automation/gitops/flux/imageupdateautomation.yaml
Expand Down Expand Up @@ -234,7 +234,7 @@ Date: Fri Nov 3 17:18:08 2023 +0000

Similarly the CodeCommit commits view will show activity:

https://console.aws.amazon.com/codesuite/codecommit/repositories/eks-workshop-gitops/commits
<ConsoleButton url="https://console.aws.amazon.com/codesuite/codecommit/repositories/eks-workshop-gitops/commits" service="codecommit" label="Open CodeCommit console"/>

We can also check the pods to see the image has been update:

Expand Down
2 changes: 1 addition & 1 deletion website/docs/automation/gitops/flux/deploy_application.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $ cp ~/environment/eks-workshop/modules/automation/gitops/flux/flux-kustomizatio

You Git directory should now look something like this which you can validate by running `tree ~/environment/flux`:

```
```text
.
├── apps
│   ├── kustomization.yaml
Expand Down
1 change: 0 additions & 1 deletion website/docs/autoscaling/compute/.descheduler/.notest

This file was deleted.

20 changes: 0 additions & 20 deletions website/docs/autoscaling/compute/.descheduler/configuration.md

This file was deleted.

52 changes: 0 additions & 52 deletions website/docs/autoscaling/compute/.descheduler/index.md

This file was deleted.

56 changes: 0 additions & 56 deletions website/docs/autoscaling/compute/.descheduler/podlife_usecase.md

This file was deleted.

48 changes: 0 additions & 48 deletions website/docs/autoscaling/compute/.descheduler/taint_usecase.md

This file was deleted.

This file was deleted.

Loading

0 comments on commit 55842c7

Please sign in to comment.