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

Create a deployment ci-stack for prod and beta deployment. #531

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
60 changes: 60 additions & 0 deletions bin/deployments/ci-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { App } from 'aws-cdk-lib';
import { Peer } from 'aws-cdk-lib/aws-ec2';
import {
readFileSync, writeFileSync, existsSync, appendFileSync,
} from 'fs';
import { CIConfigStack } from '../../lib/ci-config-stack';
import { CIStack } from '../../lib/ci-stack';
import { StageDef } from './stage-definitions';
import { FineGrainedAccessSpecs } from '../../lib/compute/auth-config';

const configPath = './bin/deployments/config.json';
let fileContent: string;
const app = new App();
const isProd = StageDef.envName === 'Prod';

let fileConfig: any = {};
try {
fileConfig = JSON.parse(readFileSync(configPath).toString('utf-8'));
} catch (error) {
// eslint-disable-next-line no-console
console.warn(error);
}

const ciConfigStack = new CIConfigStack(app, `OpenSearch-CI-Config-${StageDef.envName}`, {
});

const benchmarkFineGrainAccess: FineGrainedAccessSpecs = {
users: ['reta'],
roleName: process.env.BENCHMARK_ROLE || 'benchmark-workflow-build-access-role', // benchmark.....role
pattern: '(?i)benchmark-.*',
templateName: 'builder-template',
};

const ciStack = new CIStack(app, `OpenSearch-CI-${StageDef.envName}`, {
useSsl: fileConfig.useSsl,
authType: fileConfig.authType,
ignoreResourcesFailures: fileConfig.ignoreResourcesFailures,
adminUsers: fileConfig.adminUsers,
dataRetention: fileConfig.dataRetention,
agentAssumeRole: StageDef.agentAssumeRole,
macAgent: fileConfig.macAgent,
restrictServerAccessTo: isProd ? Peer.anyIpv4() : Peer.prefixList('pl-60b85b09'),
useProdAgents: fileConfig.useProdAgents,
enableViews: fileConfig.enableViews,
fineGrainedAccessSpecs: [benchmarkFineGrainAccess],
envVarsFilePath: './resources/envVars.yaml',
env: {
account: StageDef.AccountId,
region: process.env.CDK_DEFAULT_REGION,
},
});
ciStack.addDependency(ciConfigStack);
10 changes: 10 additions & 0 deletions bin/deployments/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"useSsl": "false",
"authType": "default",
"ignoreResourcesFailures": false,
"adminUsers": ["getsaurabh02", "gaiksaya", "peterzhuamazon", "rishabh6788", "zelinh", "prudhvigodithi", "Divyaasm", "bshien"],
"dataRetention": true,
"macAgent": true,
"useProdAgents": true,
"enableViews": true
}
26 changes: 26 additions & 0 deletions bin/deployments/stage-definitions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

export interface StageDefinition {
readonly envName: string;
readonly Region: string;
readonly Endpoint: string;
readonly AccountId: string;
readonly agentAssumeRole: string[];
}

export const StageDef: StageDefinition = {
envName: process.env.ENVIRONMENT || 'Dev',
Region: process.env.REGION || 'us-east-1',
Endpoint: process.env.ENDPOINT || '',
AccountId: process.env.ACCOUNTID || '',
agentAssumeRole: process.env.ASSUMED_ROLES ? process.env.ASSUMED_ROLES.split(',') : [
'',
],
};
7 changes: 7 additions & 0 deletions resources/envVars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
GITHUB_BOT_TOKEN_NAME: jenkins-github-bot-token
PUBLIC_ARTIFACT_URL: https://ci.opensearch.org/ci/dbc
SONATYPE_STAGING_PROFILE_ID: 78d7607cc6e881
STAGING_PROFILE_ID: 78d7607cc6e881
REPO_URL: https://aws.oss.sonatype.org/
PERF_TEST_CONFIG_LOCATION: bundles/tests/perf-test-config
BENCHMARK_TEST_CONFIG_LOCATION: bundles/tests/benchmark-test-config