mirror of
https://github.com/certd/certd.git
synced 2026-05-01 10:27:31 +08:00
perf: aws route53
This commit is contained in:
@@ -247,7 +247,7 @@ async function getAuthoritativeDnsResolver(recordName, logger = log) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
/* Resolve root domain by SOA */
|
/* Resolve root domain by SOA */
|
||||||
const domain = await resolveDomainBySoaRecord(recordNam,logger);
|
const domain = await resolveDomainBySoaRecord(recordName,logger);
|
||||||
|
|
||||||
/* Resolve authoritative NS addresses */
|
/* Resolve authoritative NS addresses */
|
||||||
logger(`获取到权威NS服务器name: ${domain}`);
|
logger(`获取到权威NS服务器name: ${domain}`);
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ async function openFormDialog() {
|
|||||||
form: {
|
form: {
|
||||||
value: true,
|
value: true,
|
||||||
helper: "是否给流水线随机设置一个时间",
|
helper: "是否给流水线随机设置一个时间",
|
||||||
|
show: compute(({ form }) => {
|
||||||
|
return form.clear !== true;
|
||||||
|
}),
|
||||||
component: {
|
component: {
|
||||||
name: "fs-dict-switch",
|
name: "fs-dict-switch",
|
||||||
vModel: "checked",
|
vModel: "checked",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||||
|
|
||||||
export const AwsRegions = [
|
export const AwsRegions = [
|
||||||
{ label: 'cn-north-1', value: 'cn-north-1' },
|
{ label: '------中国区------', value: 'cn',disabled: true },
|
||||||
{ label: 'cn-northwest-1', value: 'cn-northwest-1' },
|
{ label: '北京', value: 'cn-north-1' },
|
||||||
{ label: '---------------', value: '--',disabled: true },
|
{ label: '宁夏', value: 'cn-northwest-1' },
|
||||||
|
{ label: '------海外-----', value: 'out',disabled: true },
|
||||||
{ label: 'us-east-1', value: 'us-east-1' },
|
{ label: 'us-east-1', value: 'us-east-1' },
|
||||||
{ label: 'us-east-2', value: 'us-east-2' },
|
{ label: 'us-east-2', value: 'us-east-2' },
|
||||||
{ label: 'us-west-1', value: 'us-west-1' },
|
{ label: 'us-west-1', value: 'us-west-1' },
|
||||||
@@ -72,7 +73,7 @@ export class AwsAccess extends BaseAccess {
|
|||||||
options: AwsRegions,
|
options: AwsRegions,
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
helper: '请选择您的默认AWS区域,默认us-east-1',
|
helper: '请选择您的默认AWS区域,主要区分中国区还是海外区即可',
|
||||||
options: AwsRegions,
|
options: AwsRegions,
|
||||||
})
|
})
|
||||||
region = '';
|
region = '';
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class AwsRoute53Provider extends AbstractDnsProvider {
|
|||||||
fullRecord: fullRecord,
|
fullRecord: fullRecord,
|
||||||
type: type,
|
type: type,
|
||||||
value: value,
|
value: value,
|
||||||
action: 'CREATE',
|
action: 'UPSERT',
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
hostedZoneId: ZoneId,
|
hostedZoneId: ZoneId,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// 导入所需的 SDK 模块
|
// 导入所需的 SDK 模块
|
||||||
import { AwsAccess } from '../access.js';
|
import { AwsAccess } from '../access.js';
|
||||||
import { CertInfo } from '@certd/plugin-cert';
|
import { CertInfo } from '@certd/plugin-cert';
|
||||||
import {ILogger, utils} from '@certd/basic';
|
import { ILogger, utils } from '@certd/basic';
|
||||||
type AwsClientOptions = { access: AwsAccess; region: string, logger:ILogger };
|
type AwsClientOptions = { access: AwsAccess; region: string, logger: ILogger };
|
||||||
|
|
||||||
export class AwsClient {
|
export class AwsClient {
|
||||||
options: AwsClientOptions;
|
options: AwsClientOptions;
|
||||||
@@ -52,24 +52,24 @@ export class AwsClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async route53GetHostedZoneId(name:string) :Promise<{ZoneId:string,ZoneName:string}> {
|
async route53GetHostedZoneId(name: string): Promise<{ ZoneId: string, ZoneName: string }> {
|
||||||
const hostedZones = await this.route53ListHostedZones(name);
|
const hostedZones = await this.route53ListHostedZones(name);
|
||||||
const zoneId = hostedZones[0].Id.replace('/hostedzone/','');
|
const zoneId = hostedZones[0].Id.replace('/hostedzone/', '');
|
||||||
this.logger.info(`获取到hostedZoneId:${zoneId},name:${hostedZones[0].Name}`);
|
this.logger.info(`获取到hostedZoneId:${zoneId},name:${hostedZones[0].Name}`);
|
||||||
return {
|
return {
|
||||||
ZoneId: zoneId,
|
ZoneId: zoneId,
|
||||||
ZoneName: hostedZones[0].Name,
|
ZoneName: hostedZones[0].Name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async route53ListHostedZones(name:string) :Promise<{Id:string,Name:string}[]> {
|
async route53ListHostedZones(name: string): Promise<{ Id: string, Name: string }[]> {
|
||||||
const { ListHostedZonesByNameCommand } =await import("@aws-sdk/client-route-53"); // ES Modules import
|
const { ListHostedZonesByNameCommand } = await import("@aws-sdk/client-route-53"); // ES Modules import
|
||||||
|
|
||||||
const client = await this.route53ClientGet();
|
const client = await this.route53ClientGet();
|
||||||
const input = { // ListHostedZonesByNameRequest
|
const input = { // ListHostedZonesByNameRequest
|
||||||
DNSName: name,
|
DNSName: name,
|
||||||
};
|
};
|
||||||
const command = new ListHostedZonesByNameCommand(input);
|
const command = new ListHostedZonesByNameCommand(input);
|
||||||
const response = await this.doRequest(()=>client.send(command));
|
const response = await this.doRequest(() => client.send(command));
|
||||||
if (response.HostedZones.length === 0) {
|
if (response.HostedZones.length === 0) {
|
||||||
throw new Error(`找不到 HostedZone ${name}`);
|
throw new Error(`找不到 HostedZone ${name}`);
|
||||||
}
|
}
|
||||||
@@ -77,9 +77,10 @@ export class AwsClient {
|
|||||||
return response.HostedZones;
|
return response.HostedZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
async route53ChangeRecord(req:{
|
async route53ChangeRecord(req: {
|
||||||
hostedZoneId:string,fullRecord:string,type:string, value:string, action:"CREATE"|"DELETE"}){
|
hostedZoneId: string, fullRecord: string, type: string, value: string, action: "UPSERT" | "DELETE"
|
||||||
const { ChangeResourceRecordSetsCommand} =await import("@aws-sdk/client-route-53"); // ES Modules import
|
}) {
|
||||||
|
const { ChangeResourceRecordSetsCommand } = await import("@aws-sdk/client-route-53"); // ES Modules import
|
||||||
// const { Route53Client, ChangeResourceRecordSetsCommand } = require("@aws-sdk/client-route-53"); // CommonJS import
|
// const { Route53Client, ChangeResourceRecordSetsCommand } = require("@aws-sdk/client-route-53"); // CommonJS import
|
||||||
// import type { Route53ClientConfig } from "@aws-sdk/client-route-53";
|
// import type { Route53ClientConfig } from "@aws-sdk/client-route-53";
|
||||||
const client = await this.route53ClientGet();
|
const client = await this.route53ClientGet();
|
||||||
@@ -88,9 +89,9 @@ export class AwsClient {
|
|||||||
ChangeBatch: { // ChangeBatch
|
ChangeBatch: { // ChangeBatch
|
||||||
Changes: [ // Changes // required
|
Changes: [ // Changes // required
|
||||||
{ // Change
|
{ // Change
|
||||||
Action: req.action as any , // required
|
Action: req.action as any, // required
|
||||||
ResourceRecordSet: { // ResourceRecordSet
|
ResourceRecordSet: { // ResourceRecordSet
|
||||||
Name: req.fullRecord+".", // required
|
Name: req.fullRecord, // required
|
||||||
Type: req.type.toUpperCase() as any,
|
Type: req.type.toUpperCase() as any,
|
||||||
ResourceRecords: [ // ResourceRecords
|
ResourceRecords: [ // ResourceRecords
|
||||||
{ // ResourceRecord
|
{ // ResourceRecord
|
||||||
@@ -103,9 +104,9 @@ export class AwsClient {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.logger.info(`添加域名解析参数:${JSON.stringify(input)}`);
|
this.logger.info(`设置域名解析参数:${JSON.stringify(input)}`);
|
||||||
const command = new ChangeResourceRecordSetsCommand(input);
|
const command = new ChangeResourceRecordSetsCommand(input);
|
||||||
const response = await this.doRequest(()=>client.send(command));
|
const response = await this.doRequest(() => client.send(command));
|
||||||
console.log('Add record successful:', JSON.stringify(response));
|
console.log('Add record successful:', JSON.stringify(response));
|
||||||
await utils.sleep(3000);
|
await utils.sleep(3000);
|
||||||
return response;
|
return response;
|
||||||
@@ -120,10 +121,10 @@ export class AwsClient {
|
|||||||
// };*/
|
// };*/
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRequest<T>(call:()=>Promise<T>):Promise<T>{
|
async doRequest<T>(call: () => Promise<T>): Promise<T> {
|
||||||
try{
|
try {
|
||||||
return await call();
|
return await call();
|
||||||
}catch(err){
|
} catch (err) {
|
||||||
this.logger.error(`调用接口失败:${err.Error?.Message || err.message},requestId:${err.requestId}`);
|
this.logger.error(`调用接口失败:${err.Error?.Message || err.message},requestId:${err.requestId}`);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+15
-15
@@ -783,19 +783,19 @@ importers:
|
|||||||
packages/pro/commercial-core:
|
packages/pro/commercial-core:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@certd/basic':
|
'@certd/basic':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../core/basic
|
version: link:../../core/basic
|
||||||
'@certd/lib-server':
|
'@certd/lib-server':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../libs/lib-server
|
version: link:../../libs/lib-server
|
||||||
'@certd/pipeline':
|
'@certd/pipeline':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../core/pipeline
|
version: link:../../core/pipeline
|
||||||
'@certd/plugin-plus':
|
'@certd/plugin-plus':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../plugin-plus
|
version: link:../plugin-plus
|
||||||
'@certd/plus-core':
|
'@certd/plus-core':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../plus-core
|
version: link:../plus-core
|
||||||
'@midwayjs/core':
|
'@midwayjs/core':
|
||||||
specifier: 3.20.11
|
specifier: 3.20.11
|
||||||
@@ -880,22 +880,22 @@ importers:
|
|||||||
specifier: ^1.0.2
|
specifier: ^1.0.2
|
||||||
version: 1.0.3
|
version: 1.0.3
|
||||||
'@certd/basic':
|
'@certd/basic':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../core/basic
|
version: link:../../core/basic
|
||||||
'@certd/lib-k8s':
|
'@certd/lib-k8s':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../libs/lib-k8s
|
version: link:../../libs/lib-k8s
|
||||||
'@certd/pipeline':
|
'@certd/pipeline':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../core/pipeline
|
version: link:../../core/pipeline
|
||||||
'@certd/plugin-cert':
|
'@certd/plugin-cert':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../plugins/plugin-cert
|
version: link:../../plugins/plugin-cert
|
||||||
'@certd/plugin-lib':
|
'@certd/plugin-lib':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../plugins/plugin-lib
|
version: link:../../plugins/plugin-lib
|
||||||
'@certd/plus-core':
|
'@certd/plus-core':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../plus-core
|
version: link:../plus-core
|
||||||
ali-oss:
|
ali-oss:
|
||||||
specifier: ^6.21.0
|
specifier: ^6.21.0
|
||||||
@@ -998,7 +998,7 @@ importers:
|
|||||||
packages/pro/plus-core:
|
packages/pro/plus-core:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@certd/basic':
|
'@certd/basic':
|
||||||
specifier: ^1.37.15
|
specifier: ^1.37.16
|
||||||
version: link:../../core/basic
|
version: link:../../core/basic
|
||||||
dayjs:
|
dayjs:
|
||||||
specifier: ^1.11.7
|
specifier: ^1.11.7
|
||||||
@@ -21364,13 +21364,13 @@ snapshots:
|
|||||||
resolve: 1.22.10
|
resolve: 1.22.10
|
||||||
semver: 6.3.1
|
semver: 6.3.1
|
||||||
|
|
||||||
eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8):
|
eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8):
|
||||||
dependencies:
|
dependencies:
|
||||||
eslint: 7.32.0
|
eslint: 7.32.0
|
||||||
prettier: 2.8.8
|
prettier: 2.8.8
|
||||||
prettier-linter-helpers: 1.0.0
|
prettier-linter-helpers: 1.0.0
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
eslint-config-prettier: 8.10.0(eslint@7.32.0)
|
eslint-config-prettier: 8.10.0(eslint@8.57.0)
|
||||||
|
|
||||||
eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@8.57.0)(prettier@2.8.8):
|
eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@8.57.0)(prettier@2.8.8):
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -23784,7 +23784,7 @@ snapshots:
|
|||||||
eslint: 7.32.0
|
eslint: 7.32.0
|
||||||
eslint-config-prettier: 8.10.0(eslint@7.32.0)
|
eslint-config-prettier: 8.10.0(eslint@7.32.0)
|
||||||
eslint-plugin-node: 11.1.0(eslint@7.32.0)
|
eslint-plugin-node: 11.1.0(eslint@7.32.0)
|
||||||
eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8)
|
eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8)
|
||||||
execa: 5.1.1
|
execa: 5.1.1
|
||||||
inquirer: 7.3.3
|
inquirer: 7.3.3
|
||||||
json5: 2.2.3
|
json5: 2.2.3
|
||||||
|
|||||||
Reference in New Issue
Block a user