- Newest
- Most votes
- Most comments
Hello.
If you look at the code, there doesn't seem to be any problem, but Python will generate an error if the indentation is incorrect.
Please adjust the indentation to fit within "def __init__" as shown below.
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_rds/DatabaseCluster.html
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
....
# create an rds aurora mysql cluster
cluster = rds.DatabaseCluster(self, "MyDatabase",
It appears you're encountering some errors while trying to run cdk synth for your Cloud Quest - Cloud Infrastructure with Generative AI project. Let's address a few issues in your code:
-
The
amzn_linuxvariable is not defined. You've definedamias the Amazon Linux 2023 image, but you're usingamzn_linuxin the EC2 instance creation. Changemachine_image = amzn_linuxtomachine_image = ami. -
The
user_datavariable in the EC2 instance creation should beec2_user_data, which is what you defined earlier. -
In the RDS cluster creation, you're using
SecretValue.unsafe_plain_text()for the password. While this works, it's not recommended for production use as it exposes the password in plain text. Consider using AWS Secrets Manager for sensitive information in a production environment. -
The
availability_zoneparameter in the EC2 instance creation might cause issues if the chosen AZ doesn't have a PRIVATE_WITH_EGRESS subnet. Consider removing this parameter to let AWS choose an appropriate AZ. -
Make sure the
ec2_instance_roleexists in your AWS account before referencing it. -
The health check settings for the ALB target group are quite lenient. Consider adjusting these values for better responsiveness to instance health changes.
After making these changes, try running cdk synth again. If you still encounter issues, double-check that all imported modules are correctly installed and that you're using the latest compatible versions of the AWS CDK and its dependencies.
Remember to bootstrap your CDK environment if you haven't already done so, especially if this is a new account or region. You can do this by running cdk bootstrap before attempting to deploy.
If the error persists, you may need to check your AWS credentials and ensure you have the necessary permissions to create these resources. Also, verify that you're not hitting any service limits in your AWS account.
Sources
Cloud Quest: Infrastructure with Generative AI issue | AWS re:Post
AWS Cloud Quest - Improve Code Quality using Generative AI Project | AWS re:Post
AWS CDK: Create a Subnet and Launch Instance in it With Existing VPC | AWS re:Post
answered 2 years ago
Relevant content
asked 2 years ago

Many thanks, after playing around for a while, this worked. It looks like on the demo pictures, some were scrolled across so the full indents weren't shown