> For the complete documentation index, see [llms.txt](https://hosting.victorsmirnov.blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hosting.victorsmirnov.blog/readme.md).

# README

[![License](https://badgen.net/github/license/victorsmirnov/blog-aws-setup)](/license.md) [![TS-Standard - Typescript Standard Style Guide](https://badgen.net/badge/code%20style/ts-standard?icon=typescript)](https://github.com/standard/ts-standard)

## The AWS Cloud infrastructure for the [victorsmirnov.blog](https://victorsmirnov.blog)

The AWS CDK project to build the AWS infrastructure for the personal blog project.

### Notes

* [Why we do not have tests.](https://victorsmirnov.blog/should-we-test-aws-cdk-code/)

### Useful commands

* `npm run build` compile typescript to js.
* `npm run build:watch` watch for changes and compile.
* `cdk --profile <name> diff` compare deployed stack with current state.
* `cdk --profile <name> deploy --no-execute` create change.
* `cdk --profile <name> deploy` deploy the stack.

### Install CloudWatch agent

Documentation <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html>

Copy configuration file `src/amazon-cloudwatch-agent.json` to the server's folder `/opt/aws/amazon-cloudwatch-agent/`.

Check agent status on the server with `sudo service amazon-cloudwatch-agent status`.

And my answer on StackOverflow about how to parse time from the logs: <https://stackoverflow.com/questions/71148794/when-logging-to-cloudwatch-logs-in-a-json-format-what-is-the-name-of-the-timesta/73242108#73242108>

### Server and client certificates

```shell
./easyrsa init-pki

./easyrsa build-ca nopass

./easyrsa build-server-full server nopass

aws --profile <name> acm import-certificate --certificate fileb://easyrsa3/pki/issued/server.crt \
    --private-key fileb://easyrsa3/pki/private/server.key \
    --certificate-chain fileb://easyrsa3/pki/ca.crt

./easyrsa build-client-full <email-address> nopass
```

### Parameters for tcpdump to show incoming HTTP headers

```shell
tcpdump -A -s 0 'tcp dst port 2369 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
```

### Backup database with MySQL dump

```shell
mysqldump -h blog.cluster-csuhqkhwiw2d.eu-west-1.rds.amazonaws.com -u root -p \
    --column-statistics=0 --set-gtid-purged=OFF ghost > ghost.sql
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hosting.victorsmirnov.blog/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
