Skip to content

Commit 568acaf

Browse files
authored
Merge pull request #6 from mariswa/patch-3
Updating the commands for CodeCommit\CodeArtifact
2 parents b6c89eb + dcb8fd8 commit 568acaf

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,24 @@ The preventive controls and policies have been written as code and stored in the
3939

4040
#### Packaging & Distributing Pulumi CrossGuard Custom Policy packs using AWS CodeArtifact
4141
The folder named *customer-policy-crossguard-pkg* contains the code and the documents required for packaging a Python project into a package that can be easily distributed, without having to copy the source code. This folder needs to be uploaded into a CodeCommit repository, and future changes and distributions managed from there. Refer to this [link](https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-create-repository.html) for more information on how to create a CodeCommit repository. This repository is maintained typically by the Security Engineering team.
42+
43+
Example how to create CodeCommit repository with AWS CLI:
44+
```bash
45+
aws codecommit create-repository --repository-name custom-policy-crossguard-pkg --repository-description "Pulumi CrossGuard Policies repository"
46+
```
47+
48+
Refer to the detailed instructions how to create [a CodeArtifact domain](https://docs.aws.amazon.com/codeartifact/latest/ug/domain-create.html) and [a CodeArtifact repository](https://docs.aws.amazon.com/codeartifact/latest/ug/create-repo.html) in the domain. Example how to create CodeArtifact domain and repository using AWS CLI:
49+
```bash
50+
aws codeartifact create-domain --domain <domain-name>
51+
aws codeartifact create-repository --domain <domain-name> --domain-owner <aws-account-id> --repository <repository-name> --description "Pulumi CrossGuard policies packages"
52+
```
53+
4254
The file *setup.cfg* contains the details of the package including the name and version number. Within the *src/* folder is the project folder that will be distributed as a package to be installed via pip.
4355

4456
To generate the distribution packages, the following commands are to be run from the same folder where *pyproject.toml* is located.
4557

4658
```bash
47-
python3 -m pip install upgrade build
59+
python3 -m pip install --upgrade build
4860
python3 -m build
4961
```
5062

@@ -60,18 +72,18 @@ To upload the generated distribution archives, we use the twine package. The ins
6072

6173
```bash
6274
python3 -m pip install --upgrade twine
63-
aws codeartifact login --tool twine --repository pulumi --domain pac --domain-owner <account Id>
75+
aws codeartifact login --tool twine --repository <repository-name> --domain <domain-name> --domain-owner <aws-account-id>
6476
export TWINE_USERNAME=aws
65-
export TWINE_PASSWORD=`aws codeartifact get-authorization-token --domain acme --domain-owner <account Id> --query authorizationToken --output text`
66-
export TWINE_REPOSITORY_URL=`aws codeartifact get-repository-endpoint --domain acme --domain-owner <account Id> --repository custompolicypack --format pypi --query repositoryEndpoint --output text`
67-
python3 -m twine upload --repository pulumi dist/*
77+
export TWINE_PASSWORD=`aws codeartifact get-authorization-token --domain <domain-name> --domain-owner <aws-account-id> --query authorizationToken --output text`
78+
export TWINE_REPOSITORY_URL=`aws codeartifact get-repository-endpoint --domain <domain-name> --domain-owner <aws-account-id> --repository <repository-name> --format pypi --query repositoryEndpoint --output text`
79+
python3 -m twine upload --repository <repository-name> dist/*
6880
```
6981

7082
This will upload the package to AWS CodeArtifact. This method allows for managing versions of the policy-as-code easily.
7183
To download the package and use it within the pipeline for policy enforcement, some additional commands are to be added into the *buildspec.yml* file for the pipeline. Specifically, these following command connects to the CodeArtifact repository and enable pip to download our custom package later. A sample buildspec file has been provided here *sample-code/sample-build-file/buildspec.yaml*.
7284

7385
```bash
74-
aws codeartifact login --tool pip --repository pulumi --domain pac --domain-owner <account Id>
86+
aws codeartifact login --tool pip --repository <repository-name> --domain <domain-name> --domain-owner <aws-account-id>
7587
```
7688

7789
The preventative checks in the custom policy package cover the following items mapped to checks from *[Prowler](https://github.com/prowler-cloud/prowler)*. Prowler is an open-source security tool to perform AWS security best practices assessments, audits, incident response, continuous monitoring, hardening and forensics readiness. It contains more than 200 controls covering CIS, PCI-DSS, ISO27001, GDPR, HIPAA, FFIEC, SOC2, AWS FTR, ENS and custom security frameworks.

0 commit comments

Comments
 (0)