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(tf): Clean up pagerduty. #1206

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .aws/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Construct } from 'constructs';
import { App, S3Backend, TerraformStack } from 'cdktf';
import { AwsProvider } from '@cdktf/provider-aws';
import { config } from './config';
import { PagerdutyProvider } from '@cdktf/provider-pagerduty';
import {
createApplicationCodePipeline,
createPocketAlbApplication,
Expand All @@ -19,7 +18,6 @@ class CurationAdminTools extends TerraformStack {
defaultTags: { tags: config.tags },
});

new PagerdutyProvider(this, 'pagerduty_provider', { token: undefined });
new LocalProvider(this, 'local_provider');
new NullProvider(this, 'null_provider');

Expand Down
36 changes: 2 additions & 34 deletions .aws/src/pocketAlbApplication.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,16 @@
import {
PocketALBApplication,
PocketECSCodePipeline,
PocketPagerDuty,
} from '@pocket-tools/terraform-modules';
import { config, isDev } from './config';
import { config } from './config';
import { Construct } from 'constructs';
import { DataTerraformRemoteState } from 'cdktf';
import {
DataAwsCallerIdentity,
DataAwsRegion,
} from '@cdktf/provider-aws/lib/datasources';
import { DataAwsSnsTopic } from '@cdktf/provider-aws/lib/sns';
import { DataAwsKmsAlias } from '@cdktf/provider-aws/lib/kms';

/**
* @param scope
*/
function createPagerDuty(scope: Construct) {
const incidentManagement = new DataTerraformRemoteState(
scope,
'incident_management',
{
organization: 'Pocket',
workspaces: {
name: 'incident-management',
},
},
);

return new PocketPagerDuty(scope, 'pagerduty_policies', {
prefix: config.prefix,
service: {
criticalEscalationPolicyId: incidentManagement
.get('policy_default_critical_id')
.toString(),
nonCriticalEscalationPolicyId: incidentManagement
.get('policy_default_non_critical_id')
.toString(),
},
});
}

/**
* Create CodePipeline to build and deploy terraform and ecs
* @param app
Expand All @@ -66,8 +36,6 @@ export function createApplicationCodePipeline(
export function createPocketAlbApplication(
scope: Construct,
): PocketALBApplication {
const pagerDuty = createPagerDuty(scope);

const region = new DataAwsRegion(scope, 'region');
const caller = new DataAwsCallerIdentity(scope, 'caller');
const secretsManager = new DataAwsKmsAlias(scope, 'kms_alias', {
Expand Down Expand Up @@ -217,7 +185,7 @@ export function createPocketAlbApplication(
threshold: 25, // 25%
evaluationPeriods: 4,
period: 300, // 5 minutes
actions: isDev ? [] : [pagerDuty.snsCriticalAlarmTopic.arn],
actions: [],
},
},
});
Expand Down