## Create and prepare the Git repositories ### Create Git SSH keys 1. Create a new IAM user that will be used to interact with the CodeCommit repos from the Cloud9 environment, and from the EKS clusters by the Flux source controller. While the same IAM user is used for all the repositories in these instructions, the structure supports using different users for different repos. ```bash cd ~/environment aws iam create-user \ --user-name gitops cat >gitops-policy.json <" -f gitops ``` (Replace the `` with your company domain). 3. Add the public part of the keys generated above to the respective IAM users in your AWS account to grant access. Note down the SSH key ids printed in the terminal. ```bash cd ~/.ssh SSH_KEY_ID_GITOPS=$(aws iam upload-ssh-public-key \ --user-name gitops \ --ssh-public-key-body file://gitops.pub \ --query 'SSHPublicKey.SSHPublicKeyId' \ --output text) echo "SSH key id of user gitops: ${SSH_KEY_ID_GITOPS}" ``` 4. Create/edit `config` in `~/.ssh` to use the SSH key in `gitops` for the Git commands executed on the Cloud9 environment. ```bash cat >~/.ssh/config < ~/.ssh/codecommit_known_hosts 2>/dev/null ``` 2. Generate a Kubernetes secret file with git ssh credentials for gitops user. ```bash cd ~/environment kubectl create secret generic flux-system -n flux-system \ --from-file=identity=${HOME}/.ssh/gitops \ --from-file=identity.pub=${HOME}/.ssh/gitops.pub \ --from-file=known_hosts=${HOME}/.ssh/codecommit_known_hosts \ --dry-run=client \ --output=yaml \ >git-creds-system.yaml ``` When done, continue with the setup process [here](../../README.md#populate-and-update-the-repositories)