3
respostas

Erro ao realizar deploy do RDS - Novo problema

Muito descontente com o curso por falta de orientação e detalhes omitidos nos vídeos que atrasou muito o progresso do aprendizado, muito ruim isso levando em consideração por ser uma plataforma paga e de qualidade, a nota do curso com certeza será baixa da minha parte, mas vamos lá, ainda preciso de ajuda por favor!

Não estou conseguindo realizar o deploy do banco de dados na aws via terminal. O erro era igual deste post: https://cursos.alura.com.br/forum/topico-erro-ao-rodar-o-deploy-do-rds-358011 - na qual ele chama a vpc para retornar uma vpc pública no método

.subnets(vpc.getPublicSubnets()) .

Até ai ok, foi realizado a troca porém após a troca ele reclama que a combinação

DBInstanceClass=db.t2.micro 
Engine=mysql 
EngineVersion=8.0 

não é suportada. Parece que a instância db.t2.micro não é compatível com a versão 8.0 do MySQL no modelo de licença general-public-license.

eu dei um

aws rds describe-db-engine-versions --engine mysql

Para poder verificar quais versões do mysql eu poderia testar como alternativa, fiz teste em todas as versões do mysql e o erro persistiu.

Rds: deploying... [2/2]
Rds: creating CloudFormation changeset...
6:24:47 | CREATE_FAILED        | AWS::RDS::DBInstance           | RdspedidosF4407238
Resource handler returned message: "RDS does not support creating a DB instance with the following combination: DBInstanceClass=db.t2.micro, Engine=mysql, EngineVersion=8.0.35, LicenseModel=general
-public-license. For supported combinations of instance class and database engine version, see the documentation. (Service: Rds, Status Code: 400, Request ID: 303c17c0-0b70-489f-a264-4965a9adf058)"
(RequestToken: 55e4ac9d-3bb4-a67f-dfcb-f2a129ba9bab, HandlerErrorCode: InvalidRequest)


 ❌  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: "RDS does not support creating a DB instance with the following combination: DBInstanceClass=db.t2.micro, Engine=mysql, EngineVersion=8.0.35, LicenseModel=general-public-license. For supported combinations of instance class and database engine version, see the documentation. (Service: Rds, Status Code: 400, Request ID: 303c17c0-0b70-489f-a264-4965a9adf058)" (RequestToken: 55e4ac9d-3bb4-a67f-dfcb-f2a129ba9bab, HandlerErrorCode: InvalidRequest)
    at FullCloudFormationDeployment.monitorDeployment (/home/brunus/.nvm/versions/node/v18.19.1/lib/node_modules/aws-cdk/lib/index.js:433:10615)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.deployStack2 [as deployStack] (/home/brunus/.nvm/versions/node/v18.19.1/lib/node_modules/aws-cdk/lib/index.js:436:199343)
    at async /home/brunus/.nvm/versions/node/v18.19.1/lib/node_modules/aws-cdk/lib/index.js:436:180749

 ❌ 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: "RDS does not support creating a DB instance with the following combination: DBInstanceClass=db.t2.micro, Engine=mysql, EngineVersion=8.0.35, LicenseModel=general-public-license. For supported combinations of instance class and database engine version, see the documentation. (Service: Rds, Status Code: 400, Request ID: 303c17c0-0b70-489f-a264-4965a9adf058)" (RequestToken: 55e4ac9d-3bb4-a67f-dfcb-f2a129ba9bab, HandlerErrorCode: InvalidRequest)
    at FullCloudFormationDeployment.monitorDeployment (/home/brunus/.nvm/versions/node/v18.19.1/lib/node_modules/aws-cdk/lib/index.js:433:10615)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.deployStack2 [as deployStack] (/home/brunus/.nvm/versions/node/v18.19.1/lib/node_modules/aws-cdk/lib/index.js:436:199343)
    at async /home/brunus/.nvm/versions/node/v18.19.1/lib/node_modules/aws-cdk/lib/index.js:436:180749

The stack named Rds failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "RDS does not support creating a DB instance with the following combination: DBInstanceClass=db.t2.micro, Engine=mysql, EngineVersion=8.0.35, LicenseModel=general-public-license. For supported combinations of instance class and database engine version, see the documentation. (Service: Rds, Status Code: 400, Request ID: 303c17c0-0b70-489f-a264-4965a9adf058)" (RequestToken: 55e4ac9d-3bb4-a67f-dfcb-f2a129ba9bab, HandlerErrorCode: InvalidRequest)
3 respostas

Algúem da plataforma pode me ajudar a entender o que deu errado?

minhas versões

aws --version
aws-cli/2.15.29 Python/3.11.8 Linux/5.15.0-100-generic exe/x86_64.linuxmint.21 prompt/off

node --version
v18.19.1

npm --version
10.2.4

cdk --version
2.134.0 (build 265d769)

Minha classe Rds Stack

package com.myorg;

import java.util.Collections;

import software.amazon.awscdk.CfnOutput;
import software.amazon.awscdk.CfnParameter;
import software.amazon.awscdk.SecretValue;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.ec2.ISecurityGroup;
import software.amazon.awscdk.services.ec2.InstanceClass;
import software.amazon.awscdk.services.ec2.InstanceSize;
import software.amazon.awscdk.services.ec2.InstanceType;
import software.amazon.awscdk.services.ec2.Peer;
import software.amazon.awscdk.services.ec2.Port;
import software.amazon.awscdk.services.ec2.SecurityGroup;
import software.amazon.awscdk.services.ec2.SubnetSelection;
import software.amazon.awscdk.services.ec2.Vpc;
import software.amazon.awscdk.services.rds.Credentials;
import software.amazon.awscdk.services.rds.CredentialsFromUsernameOptions;
import software.amazon.awscdk.services.rds.DatabaseInstance;
import software.amazon.awscdk.services.rds.DatabaseInstanceEngine;
import software.amazon.awscdk.services.rds.MySqlInstanceEngineProps;
import software.amazon.awscdk.services.rds.MysqlEngineVersion;
import software.constructs.Construct;


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();
    }
}

Olha eu não nenhuma ideia do que pode ser, mas já viu essa discussão aqui sobre CREATE_FAILED? Olhando por cima são parecidos e aí está solucionado:

https://cursos.alura.com.br/forum/topico-create_failed-resolvido-374512?darkmode=false

Abraço.

Tive o mesmo problema e infelizmente o unico jeito é fazendo a instancia ser db.t3.micro, o que eu acredito que possa causar cobranças, você pode mudar para t3 mudando o InstanceClass.BURSTABLE2, InstanceSize.MICRO para InstanceClass.BURSTABLE3, InstanceSize.MICRO, acredito que o melhor a se fazer seja terminar o curso o mais rapido possivel pra derrubar esse db antes de cobranças