반응형
AWS CDK Type 스크립트 문제: 필요한 유형은 'InstanceProps' 유형에서 선언된 'securityGroups' 속성에서 왔습니다
여기서 뭘 하면 되죠?
다음 오류가 발생합니다:
Type '{ instanceType: ec2.InstanceType; securityGroup: ec2.SecurityGroup; vpc: ec2.IVpc; vpcSubnets: { subnetName: string; }; }' is not assignable to type 'InstanceProps'.
Object literal may only specify known properties, but 'securityGroup' does not exist in type 'InstanceProps'. Did you mean to write 'securityGroups'?
내 코드:
const dbClusterSecurityGroup = new ec2.SecurityGroup(this, "dbClusterSg", {
allowAllOutbound: true,
description: `Project ${projectName} Service database cluster`,
securityGroupName: `${projectName}Database`,
vpc,
});
dbClusterSecurityGroup.node.applyAspect(new cdk.Tag("Name", "serviceDatabaseCluster"));
dbClusterSecurityGroup.addIngressRule(
vpnSG,
ec2.Port.tcp(postgresDatabasePort),
);
dbClusterSecurityGroup.addIngressRule(
codeBuildProjectSG,
ec2.Port.tcp(postgresDatabasePort),
);
if (activeRegion === this.region) {
const postgresCluster = new rds.DatabaseCluster(this, "dbCluster", {
backup: {
preferredWindow: "05:00-06:00",
retention: cdk.Duration.days(30),
},
defaultDatabaseName: postgresDatabaseName,
engine: [ rds.DatabaseClusterEngine.auroraPostgres ],
engineVersion: [ rds.AuroraPostgresEngineVersion.VER_13_3 ],
engineVersion: postgresDatabaseEngineVersion,
instanceProps: {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
*securityGroup: dbClusterSecurityGroup,*
vpc,
vpcSubnets: { subnetName: "data" },
},
securityGroups: dbClusterSecurityGroup을 시도했을 때 오류가 발생했습니다:
Type 'SecurityGroup' is missing the following properties from type 'ISecurityGroup[]': length, pop, push, concat, and 26 more.
The expected type comes from property 'securityGroups' which is declared here on type 'InstanceProps'
질문 업데이트 중:
securityGroups: [dbClusterSecurityGroup]이(가) 작동했지만 지금 오류가 발생합니다
engine: [ rds.DatabaseClusterEngine.auroraPostgres ],
engineVersion: [ rds.AuroraPostgresEngineVersion.VER_13_3 ],
오류:
TSError: ⨯ Unable to compile TypeScript:
lib/database-stack.ts:120:9 - error TS2739: Type '((props: AuroraPostgresClusterEngineProps) => IClusterEngine)[]' is missing the following properties from type 'IClusterEngine': singleUserRotationApplication, multiUserRotationApplication, supportedLogTypes, bindToCluster, engineType
120 engine: [ rds.DatabaseClusterEngine.auroraPostgres ],
~~~~~~
node_modules/@aws-cdk/aws-rds/lib/cluster.d.ts:26:14
26 readonly engine: IClusterEngine;
~~~~~~
The expected type comes from property 'engine' which is declared here on type 'DatabaseClusterProps'
설명서 확인부터 시작합니다:
https://docs.aws.amazon.com/cdk/api/latest/docs/ @aws-cdk_aws-rds.InstanceProps.html
보시다시피 매개변수가 없습니다. 단지 하나가 아니라 하나의 객체를 수용합니다. 다음과 같이 보여야 합니다:
securityGroups: [dbClusterSecurityGroup]
다른 패키지에서 수입할 때도 같은 문제가 있었습니다.
import * as iam from '@aws-cdk/aws-iam';
import { Effect } from 'aws-cdk-lib/aws-iam';
수정:
import { Effect } from 'aws-cdk-lib/aws-iam';
import * as iam from 'aws-cdk-lib/aws-iam';
반응형
'개발하자' 카테고리의 다른 글
GCP의 GKE에서 IP in kubernetes에 의한 접근 제한 (0) | 2023.10.12 |
---|---|
JAVA 10+ -XX:Kubernetes 컨테이너의 MaxRAM 백분율 플래그 (0) | 2023.10.12 |
Svelte - 상위 구성 요소에서 전달되는 데이터를 기다리는 방법은 무엇입니까? (0) | 2023.10.11 |
노드 모듈을 svelte 구성 요소로 가져오려면 어떻게 해야 합니까 (0) | 2023.10.10 |
주피터 노트북의 다른 디렉토리에 py 파일 가져오기 (1) | 2023.10.10 |