Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
AWS CDK vs AWS Amplify

I have a doubt in my mind regarding AWS Amplify and CDK. In Amplify if we can create new environments and publish them to their respective buckets? Why do we need CDK? Any use case that would make CDK a better fit?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

CDK let you deploy (quite) any type of Stack that you have to manually do with cloudformation. Using cdk, you are going to create a CloudFormation stack more quicly and in a more secure way.

An example in JAVA, in order to create a new Table, you can use the following code instead of deal with YAML configuration:

 private Table CreateMasterDataTable(String TABLE_NAME) {
    return Table.Builder.create(this, TABLE_NAME + "_MasterDataTable")
            .tableName(TABLE_NAME.concat("_gvr-bic-masterdata"))
            .partitionKey(Attribute.builder().type(AttributeType.STRING).name("siteId").build())
            .removalPolicy(RemovalPolicy.RETAIN)
            .stream(StreamViewType.NEW_AND_OLD_IMAGES)
            .readCapacity(5)
            .writeCapacity(5)
            .build();
}

In order to create a new Lambda (provided an alredy existent JAR), you can use the following code instead of deal with YAML configuration:

private Function CreateSiteAggregationNowFunction() {
    Map<String, String> env = new HashMap<>();
    env.put(Constants.LAMBDA_KEY_ENV, API_NAME);
    return Function.Builder.create(this, API_NAME + "_SiteAggregationNow")
            .code(Code.fromAsset(Constants.LAMBDA_PATH_SITE_NOW))
            .handler("it.fabricalab.gvr.bic.DeviceLoader::handleRequest")
            .timeout(Duration.seconds(30))
            .environment(env)
            .functionName(API_NAME.concat("_SiteAggregationNow"))
            .runtime(Runtime.JAVA_8)
            .retryAttempts(Constants.LAMBDA_RETRY_FALLBACK)
            .memorySize(512)
            .build();
}

Than, in order to create the policy for let the lambda read from the table:

final Table masterDataTable = CreateMasterDataTable(API_NAME);
final Function siteAggregationNow = CreateSiteAggregationNowFunction();

masterDataTable .grantReadData(siteAggregationNow);

With these few lines, you have crated a CloudFormation stack with a DynamoDB table (that use stream) and a Lambda that read from this table.

over 4 years ago · Santiago Trujillo Report

0

Amplify is ok for deploying static sites, with a simple database and Cognito integration, but it is not good for managing a large number of environments or more complicated stacks. CDK is much better for managing complex infrastructure deployment. This is an example of how you can deploy static sites with CDK. https://github.com/davidsteed/awscdkstaticsite. It improves on what can be done with Amplify by dealing with security headers and certificate generation.

over 4 years ago · Santiago Trujillo Report

0

You will find out that you will need to write and edit a lot of CloudFormation templates for a production app. That gets very painful very fast.

Amplify should emit CDK code, that would give us the best of both worlds.

I used Amplify a lot initially as it could bootstrap you quickly, but since discovering CDK, CDK is the tool I use the most.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!