Skip to content

Commit

Permalink
Environment variables implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
umutykaya committed May 29, 2021
1 parent f1038b1 commit fdbe31e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
46 changes: 42 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ You can see the following file structure while you clone the project.
- [ ] Use your own AWS CLI Credentials
- [ ] Create Secret Manager with Github token
- [ ] Add Environment variables
- [ ] AWS CDK Bootstrap & Sync
- [ ] AWS CDK Bootstrap, Sync &

Suppose that you've already fork or clone the repository. Please find the main class `CDKSpringPipeline` and change the attributes and fill with your own credentials.




### Github Credentials

You need to create following
Expand All @@ -83,5 +80,46 @@ aws secretsmanager create-secret --name pipeline/spring-boot-react \
--description "spring-boot-react" \
--secret-string file://gh_token.json
```
### Environment Variables


```bash
export myIP='0.0.0.0/0'
export domainName='subdomain.example.com'
export certArn='arn:aws:acm:<region>:<account_id>:certificate/<certificate_id>'
export hostedZoneId='zone_id';
export instanceIdentifier='spring-postgres'
export rdsSecretName='pipeline/rds'
export owner='repo_owner'
export repo='repo_name'
export branch='master'
export ghbSecretName='pipeline/secret'
export clusterName='spring-cluster'
export serviceName='spring-service'
```

## Workflow
To run the project, use below scripts iteratively in your terminal.

```bash
export CDK_NEW_BOOTSTRAP=0
export CDK_DEFAULT_ACCOUNT=<account_id>
export CDK_DEFAULT_REGION=<region>
cdk bootstrap --show-template > bootstrap-template.yaml
cdk bootstrap aws://$CDK_DEFAULT_ACCOUNT/$CDK_DEFAULT_REGION --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess --template bootstrap-template.yaml
```

Install project specific dependencies.

```bash
npm install @types/node
npm install
npm run build
```
You can check diff of changes, synthesize your application stack and deploy.

```bash
cdk diff
cdk synth
cdk deploy
```
6 changes: 1 addition & 5 deletions bin/cdk-spring-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import 'source-map-support/register';
import cdk = require('@aws-cdk/core');
import { CDKSpringPipeline } from '../lib/cdk-spring-pipeline-stack';
// import { RdsBastionStack } from '../lib/rds-postgres-stack';

const app = new cdk.App();

Expand All @@ -11,7 +10,4 @@ const env = {
account: app.node.tryGetContext('account') || process.env.CDK_INTEG_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT
};

new CDKSpringPipeline(app, 'CDKSpringPipeline');
// new RdsBastionStack(app, 'RdsBastionStack');


new CDKSpringPipeline(app, 'CDKSpringPipeline');
1 change: 0 additions & 1 deletion gh_token.json

This file was deleted.

24 changes: 12 additions & 12 deletions lib/cdk-spring-pipeline-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
import acm = require('@aws-cdk/aws-certificatemanager');
import route53 = require('@aws-cdk/aws-route53');

const myIP = '24.133.236.1/32';
const domainName = 'spring.commencis-cloud.com';
const certArn = 'arn:aws:acm:eu-west-1:461902953491:certificate/df046d09-1f1c-4979-b619-4be512876959';
const hostedZoneId = 'Z05804773E1Y13CUEI66N';
const instanceIdentifier = 'spring';
const rdsSecretName = 'pipeline/rds';
const owner = 'umutykaya';
const repo = 'spring-boot-react';
const branch = 'master';
const ghbSecretName = 'pipeline/secret';
const clusterName = 'spring-cluster';
const serviceName = 'spring-service';
const myIP = process.env.myIP || '0.0.0.0/0';
const domainName = process.env.domainName || 'subdomain.example.com';
const certArn = process.env.certArn || 'arn:aws:acm:<region>:<account_id>:certificate/<certificate_id>';
const hostedZoneId = process.env.hostedZoneId || 'hosted_zone_id';
const instanceIdentifier = process.env.instanceIdentifier || 'spring-postgres';
const rdsSecretName = process.env.rdsSecretName || 'pipeline/rds';
const owner = process.env.owner || 'umutykaya';
const repo = process.env.repo || 'spring-boot-react';
const branch = process.env.branch || 'master';
const ghbSecretName = process.env.ghbSecretName || 'pipeline/secret';
const clusterName = process.env.clusterName || 'spring-cluster';
const serviceName = process.env.serviceName || 'spring-service';

export class CDKSpringPipeline extends cdk.Stack {
projectName: string = 'cdk-spring-pipeline';
Expand Down

0 comments on commit fdbe31e

Please sign in to comment.