Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include --all problem with projen commands #104

Merged
merged 9 commits into from
Jan 23, 2025
1 change: 1 addition & 0 deletions docs/content/faqs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Below we list the most common issues you might encounter during the deployment u
npx dotenv-cli -- npm run cdk deploy --all --region ${AWS_REGION} --profile $RES_ACCOUNT_AWS_PROFILE --qualifier ${CDK_QUALIFIER}
```
After performing this please do not forget to delete your CloudFormation resources on the previous INT Account.
- If you see an error `CreateRepository request is not allowed because there is no existing repository in this AWS account or AWS Organization` when performing the initial deploy step it means that your AWS Organization is not able to create new CodeCommit repositories, so you will need to choose the CodeStar option to connect to an external repository. CodeCommit repositories can only be created in AWS Organizations that already had at least 1 CodeCommit repository in a child account on July 25, 2024.
2 changes: 1 addition & 1 deletion docs/content/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Before you begin, ensure that you have the following prerequisites in place:
3. **jq Command Line JSON Processor**: Install the `jq` command-line JSON processor (version 1.5 or later).
4. **Docker**: Install Docker (version 24.0.x or later).
5. **Python and Pipenv**: If you plan to develop Python Lambda functions, ensure that you have Python (version 3.11 or later) and Pipenv (version 2023 or later) installed.
6. **Version Control System (VCS)**: The CI/CD pipeline provisions an AWS CodeCommit Git repository by default for hosting your project's source code. However, you can also choose to use your own GitHub repository.
6. **Version Control System (VCS)**: The CI/CD pipeline provisions an AWS CodeCommit Git repository by default for hosting your project's source code. However, not all accounts can use CodeCommit after July 25, 2024. You can also use [CodeConnections](https://docs.aws.amazon.com/dtconsole/latest/userguide/welcome-connections-supported-providers.html) so that the project source code is stored in Bitbucket Cloud, Github or Gitlab.

For more detailed information on prerequisites, refer to the [Prerequisites](./prerequisites.md) documentation.

Expand Down
36 changes: 30 additions & 6 deletions docs/content/getting_started/projen.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,33 @@ Follow these steps to initialize a new project using Projen:
new CdkCICDWrapper(project, {
cdkQualifier: 'wrapper',
repositoryName: 'projen-sample-wrapper',
repositoryType: 'CODECOMMIT',
repositoryType: 'CODECOMMIT', // Must be 'GITHUB' for a codestar connection
});

project.synth();
```

This code configures the project with the necessary settings for the AWS CDK and the `CdkCICDWrapper` component.
This code configures the project with the necessary settings for the AWS CDK and the `CdkCICDWrapper` component. Note that a PROD stage will not be created by default, so add it here if required. eg.

5. Execute the `npx projen` command to enable the project.
```typescript
new CdkCICDWrapper(project, {
cdkQualifier: 'wrapper',
repositoryName: 'projen-sample-wrapper',
repositoryType: 'CODECOMMIT',
stages: [ // Must be a list of all stages other than RES and may include custom stages
'DEV',
'INT',
'PROD',
]
});

```

5. Enable the project.

```bash
npx projen
```

6. Before deploying, run the following commands to ensure your project is ready:

Expand All @@ -75,7 +93,7 @@ const app = new cdk.App();

PipelineBlueprint.builder().addStack({
provide: (context) => {
// Create your stacks here
// Create your stacks here. Note that the scope parameter must be `context.scope`, not `app`
new YourStack(context.scope, `${context.blueprintProps.applicationName}YourStack`, {
applicationName: context.blueprintProps.applicationName,
stageName: context.stage,
Expand All @@ -94,6 +112,12 @@ PipelineBlueprint.builder().addStack({

The {{ project_name }} uses environment variables to store sensitive information and configuration settings. The `CdkCICDWrapper` component creates a sample `.env` file in the root directory of your project and defines the necessary variables there. You must fill out the values for these variables.

If you are using [CodeConnections](../developer_guides/vcs_github.md) to access an external git repository, add the following value to the .env file with the correct values for region, account number and connection ID:

```
CODESTAR_CONNECTION_ARN=arn:aws:codeconnections:[region]:[account number]:connection/[connection ID]
```

This file is created once, and you must maintain it manually as needed.

## Step 4: Bootstrap your stages
Expand All @@ -120,13 +144,13 @@ If you are reusing an existing CDK bootstrapping setup, you can skip this step.
npm run bootstrap INT
```

4. **Prepare the PROD stage**:
4. **Prepare the PROD stage (if configured)**:

```bash
npm run bootstrap PROD
```

**Note**: The stages have to be defined in the `.projenrc.ts` file `CdkCICDWrapperOptions.stages` variable.
**Note**: The stages have to be defined in the `.projenrc.ts` file `CdkCICDWrapperOptions.stages` variable and PROD is not configured by default.

## Step 5: Deploy the pipeline

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export class CDKCommands extends Component {
// Manage CDK tasks - Ensure env variables are read from .env file
const deployTask = project.tasks.tryFind('deploy')!;
deployTask.reset('dotenv -- npm run _deploy', { receiveArgs: true });
project.addTask('_deploy').exec('cross-env cdk deploy --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
project
.addTask('_deploy')
.exec('cross-env cdk deploy --all --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });

project.addTask('workbench').exec('dotenv -- npm run _workbench', { receiveArgs: true });
project
Expand All @@ -107,6 +109,13 @@ export class CDKCommands extends Component {
receiveArgs: true,
});

project.addTask('workbenchAll').exec('dotenv -- npm run _workbench', { receiveArgs: true });
project
.addTask('_workbenchAll')
.exec(`cross-env cdk deploy --all --profile $${this.workbenchStage}_ACCOUNT_AWS_PROFILE -c "workbench=true"`, {
receiveArgs: true,
});

project.addTask('workbench:synth').exec('dotenv -- npm run _workbench:synth', { receiveArgs: true });
project
.addTask('_workbench:synth')
Expand All @@ -117,7 +126,7 @@ export class CDKCommands extends Component {
project.addTask('workbench:destroy').exec('dotenv -- npm run _workbench:destroy', { receiveArgs: true });
project
.addTask('_workbench:destroy')
.exec(`cross-env cdk destroy --profile $${this.workbenchStage}_ACCOUNT_AWS_PROFILE -c "workbench=true"`, {
.exec(`cross-env cdk destroy --all --profile $${this.workbenchStage}_ACCOUNT_AWS_PROFILE -c "workbench=true"`, {
receiveArgs: true,
});

Expand Down Expand Up @@ -165,7 +174,7 @@ export class CDKCommands extends Component {
project.tasks.tryFind('destroy')?.reset('dotenv -- npm run _destroy', { receiveArgs: true });
project
.addTask('_destroy')
.exec('cross-env cdk destroy --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
.exec('cross-env cdk destroy --all --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
project.tasks.tryFind('synth')?.reset('dotenv -- npm run _synth', { receiveArgs: true });
project.addTask('_synth').exec('cross-env cdk synth --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
project.tasks.tryFind('diff')?.reset('dotenv -- npm run _diff', { receiveArgs: true });
Expand Down
15 changes: 12 additions & 3 deletions packages/@cdklabs/cdk-cicd-wrapper/src/projen/CDKCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export class CDKCommands extends Component {
// Manage CDK tasks - Ensure env variables are read from .env file
const deployTask = project.tasks.tryFind('deploy')!;
deployTask.reset('dotenv -- npm run _deploy', { receiveArgs: true });
project.addTask('_deploy').exec('cross-env cdk deploy --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
project
.addTask('_deploy')
.exec('cross-env cdk deploy --all --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });

project.addTask('workbench').exec('dotenv -- npm run _workbench', { receiveArgs: true });
project
Expand All @@ -107,6 +109,13 @@ export class CDKCommands extends Component {
receiveArgs: true,
});

project.addTask('workbenchAll').exec('dotenv -- npm run _workbench', { receiveArgs: true });
project
.addTask('_workbenchAll')
.exec(`cross-env cdk deploy --all --profile $${this.workbenchStage}_ACCOUNT_AWS_PROFILE -c "workbench=true"`, {
receiveArgs: true,
});

project.addTask('workbench:synth').exec('dotenv -- npm run _workbench:synth', { receiveArgs: true });
project
.addTask('_workbench:synth')
Expand All @@ -117,7 +126,7 @@ export class CDKCommands extends Component {
project.addTask('workbench:destroy').exec('dotenv -- npm run _workbench:destroy', { receiveArgs: true });
project
.addTask('_workbench:destroy')
.exec(`cross-env cdk destroy --profile $${this.workbenchStage}_ACCOUNT_AWS_PROFILE -c "workbench=true"`, {
.exec(`cross-env cdk destroy --all --profile $${this.workbenchStage}_ACCOUNT_AWS_PROFILE -c "workbench=true"`, {
receiveArgs: true,
});

Expand Down Expand Up @@ -165,7 +174,7 @@ export class CDKCommands extends Component {
project.tasks.tryFind('destroy')?.reset('dotenv -- npm run _destroy', { receiveArgs: true });
project
.addTask('_destroy')
.exec('cross-env cdk destroy --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
.exec('cross-env cdk destroy --all --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
project.tasks.tryFind('synth')?.reset('dotenv -- npm run _synth', { receiveArgs: true });
project.addTask('_synth').exec('cross-env cdk synth --profile $RES_ACCOUNT_AWS_PROFILE', { receiveArgs: true });
project.tasks.tryFind('diff')?.reset('dotenv -- npm run _diff', { receiveArgs: true });
Expand Down
Loading