More Related Content Similar to London Microservices Meetup: Lessons learnt adopting microservices (20) More from Cobus Bernard (20) London Microservices Meetup: Lessons learnt adopting microservices2. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Agenda
Background to situation
Technical Challenges
People challenges
Learnings
Dad Joke
3. © 2020, Amazon Web Services, Inc. or its Affiliates.
About me
• Developer for 15 years
• AWS Customer for 8 years
@cobusbernard
cobusbernard
cobusbernard
CobusCloud
{ af-south-1 }
7. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #1:
Standardising the builds
11. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
12. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
13. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #2:
Infrastructure enablement
14. © 2020, Amazon Web Services, Inc. or its Affiliates.
If you build it…
You must maintain it
15. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
resource "aws_ecs_task_definition" ”my_service" {
family = ”my_service"
container_definitions = <<DEFINITION
[
{
"cpu": 128,
"environment": [{
"name": "SECRET","value": "KEY"
}],
"essential": true,
"image": ”cobus:lockdown_beard",
"memory": 128, "name": ”my_service"
}]
DEFINITION
}
16. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
# The template file for the IAM policy
...
resource "aws_iam_role" ”my_service" {
name = ”my_service_role"
assume_role_policy =
"${file("templates/my_service_iam_role_policy.json")}"
}
resource "aws_iam_role_policy" ”my_service" {
name = ”my_service_policy"
role = "${aws_iam_role.my_ service.id}"
policy = "${data.template_file.my_service_policy
.rendered}"
}
17. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
resource "aws_ecs_service" "my_service" {
name = "my_service"
cluster = aws_ecs_cluster.foo.id
task_definition = aws_ecs_task_definition.my_ecs.arn
desired_count = var.desired_count
iam_role = aws_iam_role.my_service.arn
load_balancer {
target_group_arn = aws_lb_target_group.my_service.arn
container_name = "my_service"
container_port = 8080
}
}
18. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
resource "aws_sqs_queue" "myservice" {
name = "${var.service-name}-queue"
delay_seconds = 90
max_message_size = 2048
message_retention_seconds = 86400
receive_wait_time_seconds = 10
}
23. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #3:
Configs & Secrets
24. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS
KMS
Dev
Encryption
Key
Service
Encryption
Key
Value Dev Encrypted Service
Encrypted
25. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
data "aws_kms_secrets" "db_credentials" {
secret {
name = "db_username"
payload = "AQECAHgaPa0_ReallyLongStringHere_AS#SG=="
context = {
service = "my_service"
}
}
secret {
name = "db_password"
payload = "AQECAHg_ItIsStillGoing..._AS#SG=="
}
}
26. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
resource "aws_rds_cluster" "my_service" {
# ... other configuration ...
main_username =
data.aws_kms_secrets.db_credentials
.plaintext["db_username"]
main_password =
data.aws_kms_secrets.db_credentials
.plaintext["db_password"]
}
27. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
module "config_db_url" {
source = "git@github.com/Acme/tf-modules/config"
name = "db_url"
value = var.db_url
}
module "config_db_username" {
source = "git@github.com/Acme/tf-modules/secret"
name = "db_username"
value = var.db_secret
}
30. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
32. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #4:
People don’t like change
33. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Real tears
34. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #5:
People like constant change even
less
37. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
upgrade:
@echo 'Preparing to upgrade the Makefile and common
Terraform files...’
@read -p "Press enter to continue"
@mkdir _upgrade
@git clone git@github.com:<my-org>/terraform.git _upgra
@echo "Upgrading common.tf..."
@rm -f common.tf
@mv _upgrade/framework/common.tf ./
@echo "Upgrading environment var files..."
@rm -f framework/*
@mv _upgrade/framework/*.tfvars framework/
38. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
@echo "Upgrading Makefile..."
@rm -f Makefile
@mv _upgrade/Makefile ./
@echo "Upgrading remotes.tf.sample..."
@rm -f remotes.tf.sample
@mv _upgrade/framework/remotes.tf.sample ./
@echo "Cleaning up"
@rm -rf _upgrade
39. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #6:
Make the right choice,
the easy choice
41. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
module "service" {
source = "git@github.com/Acme/tf-modules/service"
name = "ordering"
instance_size = var.service_instance_size
instance_count = var.service_instance_count
}
42. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
module "config_db_url" {
source = "git@github.com/Acme/tf-modules/config"
name = "db_url"
value = var.db_url
}
module "config_db_username" {
source = "git@github.com/Acme/tf-modules/secret"
name = "db_username"
value = var.db_secret
}
45. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #7:
What you think is an achievement
might not matter to business
47. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #8:
Some people won’t change
49. © 2020, Amazon Web Services, Inc. or its Affiliates.
Lesson #9:
Should probably not have split the
monolith
50. © 2020, Amazon Web Services, Inc. or its Affiliates.© 2020, Amazon Web Services, Inc. or its Affiliates.
Monolith
Does everything
Monoliths are OK
51. © 2020, Amazon Web Services, Inc. or its Affiliates.
Promised Dad Joke:
What didYoda say when he
saw himself in 4k?
53. Thank you!
© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Cobus Bernard
Sr Developer Advocate
Amazon Web Services
@cobusbernard
cobusbernard
cobusbernard
CobusCloud
Editor's Notes Engine yard
Heroku
Some AWS (manually deployed on AWS) Engine yard
Heroku
Some AWS (manually deployed on AWS) Let’s put run in a container, how hard can this be? Learn how to work in a team Started with the least critical services first
Then found different version of ruby, upgraded them
Then found customized v2.7 of ruby
1000+ tests failing
Build took 45mins
Move from CircleCI -> AWS CodeBuild
Test image -> to run tests. Hmmm … Hmmm … Hmmm … Hmmm … Hmmm … Hmmm … Hmmm … Figure out how make the upading automatic / easy Engine yard
Heroku
Some AWS (manually deployed on AWS) Engine yard
Heroku
Some AWS (manually deployed on AWS) So proud for „finishing the EY migration“, while everything was moved, there still was 2 instances running that ran reports. Data bus
Data ownership
Copy & syncing data
Hard to do reports