Skip to content

Commit

Permalink
feat: reusable security groups
Browse files Browse the repository at this point in the history
  • Loading branch information
gagan1510 committed Sep 6, 2021
1 parent 510556c commit 90550e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ new MicroService(scope: Construct, id: string, props: MicroServiceProps)

---

##### `securityGroupProps`<sup>Optional</sup> <a name="@smallcase/aws-cdk-microservice.MicroService.property.securityGroupProps"></a>

- *Type:* [`@smallcase/aws-cdk-microservice.InternalSG`](#@smallcase/aws-cdk-microservice.InternalSG)

---

##### `sslEnabled`<sup>Optional</sup> <a name="@smallcase/aws-cdk-microservice.MicroService.property.sslEnabled"></a>

- *Type:* `boolean`
Expand Down Expand Up @@ -884,6 +890,12 @@ const microServiceProps: MicroServiceProps = { ... }

---

##### `securityGroupProps`<sup>Optional</sup> <a name="@smallcase/aws-cdk-microservice.MicroServiceProps.property.securityGroupProps"></a>

- *Type:* [`@smallcase/aws-cdk-microservice.InternalSG`](#@smallcase/aws-cdk-microservice.InternalSG)

---

##### `sslEnabled`<sup>Optional</sup> <a name="@smallcase/aws-cdk-microservice.MicroServiceProps.property.sslEnabled"></a>

- *Type:* `boolean`
Expand Down
6 changes: 5 additions & 1 deletion src/constructs/microservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CfnAutoScalingGroup } from '@aws-cdk/aws-autoscaling';
import { EbsDeviceVolumeType } from '@aws-cdk/aws-ec2';
import { Effect, PolicyStatement, Role, ServicePrincipal } from '@aws-cdk/aws-iam';
import { Construct } from '@aws-cdk/core';
import { InternalSG } from '..';
import { AutoScaler, IngressRule, InternalRole } from './autoScalingGroup';
import { Deployment } from './deployment';
import { BalancerEntry } from './network';
Expand Down Expand Up @@ -31,6 +32,7 @@ export interface MicroServiceProps {
readonly createCodedeployApplication?: boolean;
readonly deploymentPolicies?: string[];
readonly applicationType?: string;
readonly securityGroupProps?: InternalSG;
}
export class MicroService extends Construct {

Expand All @@ -56,6 +58,7 @@ export class MicroService extends Construct {
public readonly createCodedeployApplication?: boolean;
public readonly deploymentPolicies?: string[];
public readonly applicationType?: string;
public readonly securityGroupProps?: InternalSG;

constructor(scope: Construct, id: string, props: MicroServiceProps) {
super(scope, id);
Expand All @@ -82,6 +85,7 @@ export class MicroService extends Construct {
this.createCodedeployApplication = props.createCodedeployApplication ?? false;
this.deploymentPolicies = props.deploymentPolicies ?? [];
this.applicationType = props.applicationType ?? 'new';
this.securityGroupProps = props.securityGroupProps;

const resourceNamePrefix = this.env + '-' + this.appName;
const asg = new AutoScaler(this, resourceNamePrefix + '-as', {
Expand Down Expand Up @@ -112,7 +116,7 @@ export class MicroService extends Construct {
type: 'existing',
vpcName: this.vpc,
},
securityGroup: {
securityGroup: this.securityGroupProps ?? {
type: 'new',
allowAllOutbound: true,
securityGroupName: resourceNamePrefix + '-SG',
Expand Down

0 comments on commit 90550e6

Please sign in to comment.