s3 impl
This commit is contained in:
@@ -11,9 +11,7 @@ import { RequestContext } from '../_context/request.context';
|
||||
|
||||
@Injectable()
|
||||
export class KmsService {
|
||||
constructor(
|
||||
private readonly prismaService: PrismaService,
|
||||
) {}
|
||||
constructor(private readonly prismaService: PrismaService) {}
|
||||
|
||||
async findOneByRef(ref: string, awsProperties: AwsProperties): Promise<KmsKey> {
|
||||
if (ref.startsWith('arn')) {
|
||||
@@ -28,25 +26,24 @@ export class KmsService {
|
||||
}
|
||||
|
||||
async findOneById(accountId: string, region: string, ref: string): Promise<KmsKey> {
|
||||
|
||||
const [alias, record] = await Promise.all([
|
||||
this.prismaService.kmsAlias.findFirst({
|
||||
include: {
|
||||
kmsKey: true
|
||||
kmsKey: true,
|
||||
},
|
||||
where: {
|
||||
accountId,
|
||||
region,
|
||||
name: ref,
|
||||
}
|
||||
},
|
||||
}),
|
||||
this.prismaService.kmsKey.findFirst({
|
||||
where: {
|
||||
accountId,
|
||||
region,
|
||||
id: ref,
|
||||
}
|
||||
})
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
if (!alias?.kmsKey && !record) {
|
||||
@@ -65,7 +62,7 @@ export class KmsService {
|
||||
kmsKeyId,
|
||||
name: {
|
||||
gte: marker,
|
||||
}
|
||||
},
|
||||
},
|
||||
take,
|
||||
orderBy: {
|
||||
@@ -84,7 +81,7 @@ export class KmsService {
|
||||
region,
|
||||
name: {
|
||||
gte: marker,
|
||||
}
|
||||
},
|
||||
},
|
||||
take,
|
||||
orderBy: {
|
||||
@@ -97,7 +94,7 @@ export class KmsService {
|
||||
|
||||
async createKmsKey(data: Prisma.KmsKeyCreateInput): Promise<KmsKey> {
|
||||
const record = await this.prismaService.kmsKey.create({
|
||||
data
|
||||
data,
|
||||
});
|
||||
return new KmsKey(record);
|
||||
}
|
||||
@@ -111,7 +108,33 @@ export class KmsService {
|
||||
|
||||
async createAlias(data: Prisma.KmsAliasCreateInput) {
|
||||
await this.prismaService.kmsAlias.create({
|
||||
data
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
async findAliasByName(accountId: string, region: string, name: string): Promise<KmsAlias | null> {
|
||||
const record = await this.prismaService.kmsAlias.findUnique({
|
||||
where: {
|
||||
accountId_region_name: {
|
||||
accountId,
|
||||
region,
|
||||
name,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return record ? new KmsAlias(record) : null;
|
||||
}
|
||||
|
||||
async deleteAlias(accountId: string, region: string, name: string): Promise<void> {
|
||||
await this.prismaService.kmsAlias.delete({
|
||||
where: {
|
||||
accountId_region_name: {
|
||||
accountId,
|
||||
region,
|
||||
name,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user