Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro ao Rodar o Deploy do Rds

Boa tarde,

ao tentar subir o deploy do Rds exibe o seguinte erro no terminal:

14:58:53 | CREATE_FAILED        | AWS::RDS::DBSubnetGroup        | RdspedidosSubnetGroupA487F029
Resource handler returned message: "Subnet IDs are required. (Service: Rds, Status Code: 400, Request ID: 48bc5480-709f-4563-9f30-e4ec8cc9b675)" (RequestToken: 6b415d73-aaa0-46b7-2424-eced27038e01, HandlerErrorCode: In
validRequest)


 ❌  Rds failed: Error: The stack named Rds failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Subnet IDs are required. (Service: Rds, Status Code: 400, Request ID: 48bc5480-709f-4563-9f30-e4ec8cc9b675)" (RequestToken: 6b415d73-aaa0-46b7-2424-eced27038e01, HandlerErrorCode: InvalidRequest)
    at FullCloudFormationDeployment.monitorDeployment (/usr/local/lib/node_modules/aws-cdk/lib/index.js:431:10615)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.deployStack2 [as deployStack] (/usr/local/lib/node_modules/aws-cdk/lib/index.js:434:196750)
    at async /usr/local/lib/node_modules/aws-cdk/lib/index.js:434:178719

 ❌ Deployment failed: Error: The stack named Rds failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Subnet IDs are required. (Service: Rds, Status Code: 400, Request ID: 48bc5480-709f-4563-9f30-e4ec8cc9b675)" (RequestToken: 6b415d73-aaa0-46b7-2424-eced27038e01, HandlerErrorCode: InvalidRequest)
    at FullCloudFormationDeployment.monitorDeployment (/usr/local/lib/node_modules/aws-cdk/lib/index.js:431:10615)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.deployStack2 [as deployStack] (/usr/local/lib/node_modules/aws-cdk/lib/index.js:434:196750)
    at async /usr/local/lib/node_modules/aws-cdk/lib/index.js:434:178719

The stack named Rds failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Subnet IDs are required. (Service: Rds, Status Code: 400, Request ID: 48bc5480-709f-4563-9f30-e4ec8cc9b675)" (RequestToken: 6b415d73-aaa0-46b7-2424-eced27038e01, HandlerErrorCode: InvalidRequest)

Alguém já passou por esse problema? Muito obrigado!

2 respostas

Eu até verifiquei um problema semelhante no seguinte tópico(https://cursos.alura.com.br/forum/topico-duvida-cdk-deploy-rds-subnet-ids-are-required-332701), mas

não entendi em qual arquivo deveria ser modificado, visto que os trechos de códigos foram colados sugerido através das aulas.

solução!

Boa tarde, consegui subir trocando o código

package com.myorg;

import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.ec2.InstanceType;
import software.amazon.awscdk.services.rds.*;
import software.constructs.Construct;


import java.util.Collections;


public class AluraRdsStack extends Stack {
    public AluraRdsStack(final Construct scope, final String id, final Vpc vpc) {
        this(scope, id, null, vpc);
    }

    public AluraRdsStack(final Construct scope, final String id, final StackProps props, final Vpc vpc) {
        super(scope, id, props);

        CfnParameter senha = CfnParameter.Builder.create (this, "senha")
        .type("String")
                .description("Senha do database pedidos-ms")
                .build();

        ISecurityGroup iSecurityGroup = SecurityGroup.fromSecurityGroupId(this, id, vpc.getVpcDefaultSecurityGroup());
        iSecurityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(3306));

        DatabaseInstance database = DatabaseInstance.Builder
                .create(this, "Rds-pedidos")
                .instanceIdentifier("alura-aws-pedido-db")
                .engine(DatabaseInstanceEngine.mysql(MySqlInstanceEngineProps.builder()
                        .version(MysqlEngineVersion.VER_8_0)
                        .build()))
                .vpc(vpc)
                .credentials(Credentials.fromUsername("admin",
                CredentialsFromUsernameOptions.builder()
                        .password(SecretValue.unsafePlainText(senha.getValueAsString()))
                        .build()))
                .instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO))
                .multiAz(false)
                .allocatedStorage(10)
                .securityGroups(Collections.singletonList(iSecurityGroup))
                .vpcSubnets(SubnetSelection.builder()
                        .subnets(vpc.getPublicSubnets())
                        .build())
                .build();

        CfnOutput.Builder.create(this, "pedidos-db-endpoint")
                .exportName("pedidos-db-endpoint")
                .value(database.getDbInstanceEndpointAddress())
                .build();

        CfnOutput.Builder.create(this, "pedidos-db-senha")
                .exportName("pedidos-db-senha")
                .value(senha.getValueAsString())
                .build();
    }
}

Fiz a troca do metodo

vpc.getPrivateSubnets()

para o

vpc.getPublicSubnets()

no trecho :

DatabaseInstance database = DatabaseInstance.Builder
                .create(this, "Rds-pedidos")
                .instanceIdentifier("alura-aws-pedido-db")
                .engine(DatabaseInstanceEngine.mysql(MySqlInstanceEngineProps.builder()
                        .version(MysqlEngineVersion.VER_8_0)
                        .build()))
                .vpc(vpc)
                .credentials(Credentials.fromUsername("admin",
                CredentialsFromUsernameOptions.builder()
                        .password(SecretValue.unsafePlainText(senha.getValueAsString()))
                        .build()))
                .instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO))
                .multiAz(false)
                .allocatedStorage(10)
                .securityGroups(Collections.singletonList(iSecurityGroup))
                .vpcSubnets(SubnetSelection.builder()
                        .subnets(vpc.getPublicSubnets())
                        .build())
                .build();

Espero ajudar quem passar pelo mesmo problema.