[{"data":1,"prerenderedAt":2060},["ShallowReactive",2],{"post-manage-aws-infrastructure-with-terraform":3,"rel-manage-aws-infrastructure-with-terraform":1978,"sib-manage-aws-infrastructure-with-terraform":1979},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"layout":11,"subtitle":9,"image":12,"optimized_image":12,"category":13,"tags":14,"author":18,"paginate":6,"body":19,"_type":1972,"_id":1973,"_source":1974,"_file":1975,"_stem":1976,"_extension":1977},"/posts/manage-aws-infrastructure-with-terraform","posts",false,"","Bootstrap complete Java application infrastructure in AWS with Terraform","How to bootstrap a Java + MySql application infrastructure with terraform","2020-12-02T11:00:00.000Z","post","/assets/img/uploads/infrastructure.jpg","infrastructure",[15,16,17],"terraform","aws","java","jaimedearcos",{"type":20,"children":21,"toc":1965},"root",[22,36,43,48,58,64,69,104,109,548,554,559,981,987,999,1893,1899,1904,1938,1959],{"type":23,"tag":24,"props":25,"children":26},"element","p",{},[27,34],{"type":23,"tag":28,"props":29,"children":30},"strong",{},[31],{"type":32,"value":33},"text","Terraform",{"type":32,"value":35}," provides a way of describe infrastructure as code. Terraform will manage the communication with the\ninfrastructure provider (Amazon AWS in this example) to create, update or delete infrastructure resources.",{"type":23,"tag":37,"props":38,"children":40},"h2",{"id":39},"bootstrap-elasticbeanstalk-rds-mysql-application",[41],{"type":32,"value":42},"Bootstrap ElasticBeanstalk + RDS MySql application",{"type":23,"tag":24,"props":44,"children":45},{},[46],{"type":32,"value":47},"In the following example we are going to bootstrap the necessary infrastructure to serve a Java API connected to RDS\nMySql database.",{"type":23,"tag":24,"props":49,"children":50},{},[51],{"type":23,"tag":52,"props":53,"children":57},"img",{"alt":54,"src":55,"title":56},"aws infrastructure diagram","/assets/img/uploads/terraform-basic.png","Aws infrastructure diagram",[],{"type":23,"tag":37,"props":59,"children":61},{"id":60},"step-1-networking",[62],{"type":32,"value":63},"Step 1 - Networking",{"type":23,"tag":24,"props":65,"children":66},{},[67],{"type":32,"value":68},"We are going to create a terraform module for VPC and other networking resources:",{"type":23,"tag":70,"props":71,"children":72},"ul",{},[73,84,94],{"type":23,"tag":74,"props":75,"children":76},"li",{},[77,82],{"type":23,"tag":28,"props":78,"children":79},{},[80],{"type":32,"value":81},"VPC",{"type":32,"value":83}," - Virtual Private Cloud: Is a logical group of resources that are isolated from other VPCs and other customers\nof the Public Cloud.",{"type":23,"tag":74,"props":85,"children":86},{},[87,92],{"type":23,"tag":28,"props":88,"children":89},{},[90],{"type":32,"value":91},"VPC Subnet",{"type":32,"value":93}," : A VPC Subnet is defined by a subrange of the network IP addresses assigned to the VPC.",{"type":23,"tag":74,"props":95,"children":96},{},[97,102],{"type":23,"tag":28,"props":98,"children":99},{},[100],{"type":32,"value":101},"Security Group",{"type":32,"value":103}," : The VPC Security Groups are the way AWS implements firewalls between instances in the VPC.\nIn a VPC all inbound and outbound network traffic is denied by default. In order to allow traffic, a security group\nis defined and rules are assigned to the Security Group.",{"type":23,"tag":24,"props":105,"children":106},{},[107],{"type":32,"value":108},"The following is a terraform module to group all the needed networking resources in just one file.",{"type":23,"tag":110,"props":111,"children":115},"pre",{"className":112,"code":113,"language":114,"meta":7,"style":7},"language-ruby shiki shiki-themes github-dark github-light","resource \"aws_vpc\" \"_\" {\n  cidr_block = var.vpc_cidr\n  enable_dns_support   = var.enable_dns_support\n  enable_dns_hostnames = var.enable_dns_hostnames\n  tags = {\n    Name = \"${var.app-name}-vpc\"\n  }\n}\n\nresource \"aws_internet_gateway\" \"gateway\" {\n  vpc_id = aws_vpc._.id\n  tags = {\n    Name = \"${var.app-name}-gateway\"\n  }\n}\n\nresource \"aws_route_table\" \"route_table\" {\n  vpc_id = aws_vpc._.id\n\n  dynamic \"route\" {\n    for_each = var.routes\n\n    content {\n      cidr_block     = route.value.cidr_block\n      gateway_id     = aws_internet_gateway.gateway.id\n      instance_id    = route.value.instance_id\n      nat_gateway_id = route.value.nat_gateway_id\n    }\n  }\n  tags = {\n    Name = \"${var.app-name}-route-table\"\n  }\n}\nresource \"aws_subnet\" \"subnet-a\" {\n  vpc_id                  = aws_vpc._.id\n  cidr_block              = \"10.0.32.0/20\"\n  availability_zone       = \"${var.region}a\"\n  map_public_ip_on_launch = true\n  tags = {\n    Name = \"${var.app-name}-subnet-a\"\n  }\n}\n \noutput \"_\" {\n  value = {\n    vpc_id = aws_vpc._.id\n    subnet_a = aws_subnet.subnet-a.id \n  }\n}\n","ruby",[116],{"type":23,"tag":117,"props":118,"children":119},"code",{"__ignoreMap":7},[120,131,140,149,158,167,176,185,194,204,213,222,230,239,247,255,263,272,280,288,297,306,314,323,332,341,350,359,368,376,384,393,401,409,418,427,436,445,454,462,471,479,487,496,505,514,523,532,540],{"type":23,"tag":121,"props":122,"children":125},"span",{"class":123,"line":124},"line",1,[126],{"type":23,"tag":121,"props":127,"children":128},{},[129],{"type":32,"value":130},"resource \"aws_vpc\" \"_\" {\n",{"type":23,"tag":121,"props":132,"children":134},{"class":123,"line":133},2,[135],{"type":23,"tag":121,"props":136,"children":137},{},[138],{"type":32,"value":139},"  cidr_block = var.vpc_cidr\n",{"type":23,"tag":121,"props":141,"children":143},{"class":123,"line":142},3,[144],{"type":23,"tag":121,"props":145,"children":146},{},[147],{"type":32,"value":148},"  enable_dns_support   = var.enable_dns_support\n",{"type":23,"tag":121,"props":150,"children":152},{"class":123,"line":151},4,[153],{"type":23,"tag":121,"props":154,"children":155},{},[156],{"type":32,"value":157},"  enable_dns_hostnames = var.enable_dns_hostnames\n",{"type":23,"tag":121,"props":159,"children":161},{"class":123,"line":160},5,[162],{"type":23,"tag":121,"props":163,"children":164},{},[165],{"type":32,"value":166},"  tags = {\n",{"type":23,"tag":121,"props":168,"children":170},{"class":123,"line":169},6,[171],{"type":23,"tag":121,"props":172,"children":173},{},[174],{"type":32,"value":175},"    Name = \"${var.app-name}-vpc\"\n",{"type":23,"tag":121,"props":177,"children":179},{"class":123,"line":178},7,[180],{"type":23,"tag":121,"props":181,"children":182},{},[183],{"type":32,"value":184},"  }\n",{"type":23,"tag":121,"props":186,"children":188},{"class":123,"line":187},8,[189],{"type":23,"tag":121,"props":190,"children":191},{},[192],{"type":32,"value":193},"}\n",{"type":23,"tag":121,"props":195,"children":197},{"class":123,"line":196},9,[198],{"type":23,"tag":121,"props":199,"children":201},{"emptyLinePlaceholder":200},true,[202],{"type":32,"value":203},"\n",{"type":23,"tag":121,"props":205,"children":207},{"class":123,"line":206},10,[208],{"type":23,"tag":121,"props":209,"children":210},{},[211],{"type":32,"value":212},"resource \"aws_internet_gateway\" \"gateway\" {\n",{"type":23,"tag":121,"props":214,"children":216},{"class":123,"line":215},11,[217],{"type":23,"tag":121,"props":218,"children":219},{},[220],{"type":32,"value":221},"  vpc_id = aws_vpc._.id\n",{"type":23,"tag":121,"props":223,"children":225},{"class":123,"line":224},12,[226],{"type":23,"tag":121,"props":227,"children":228},{},[229],{"type":32,"value":166},{"type":23,"tag":121,"props":231,"children":233},{"class":123,"line":232},13,[234],{"type":23,"tag":121,"props":235,"children":236},{},[237],{"type":32,"value":238},"    Name = \"${var.app-name}-gateway\"\n",{"type":23,"tag":121,"props":240,"children":242},{"class":123,"line":241},14,[243],{"type":23,"tag":121,"props":244,"children":245},{},[246],{"type":32,"value":184},{"type":23,"tag":121,"props":248,"children":250},{"class":123,"line":249},15,[251],{"type":23,"tag":121,"props":252,"children":253},{},[254],{"type":32,"value":193},{"type":23,"tag":121,"props":256,"children":258},{"class":123,"line":257},16,[259],{"type":23,"tag":121,"props":260,"children":261},{"emptyLinePlaceholder":200},[262],{"type":32,"value":203},{"type":23,"tag":121,"props":264,"children":266},{"class":123,"line":265},17,[267],{"type":23,"tag":121,"props":268,"children":269},{},[270],{"type":32,"value":271},"resource \"aws_route_table\" \"route_table\" {\n",{"type":23,"tag":121,"props":273,"children":275},{"class":123,"line":274},18,[276],{"type":23,"tag":121,"props":277,"children":278},{},[279],{"type":32,"value":221},{"type":23,"tag":121,"props":281,"children":283},{"class":123,"line":282},19,[284],{"type":23,"tag":121,"props":285,"children":286},{"emptyLinePlaceholder":200},[287],{"type":32,"value":203},{"type":23,"tag":121,"props":289,"children":291},{"class":123,"line":290},20,[292],{"type":23,"tag":121,"props":293,"children":294},{},[295],{"type":32,"value":296},"  dynamic \"route\" {\n",{"type":23,"tag":121,"props":298,"children":300},{"class":123,"line":299},21,[301],{"type":23,"tag":121,"props":302,"children":303},{},[304],{"type":32,"value":305},"    for_each = var.routes\n",{"type":23,"tag":121,"props":307,"children":309},{"class":123,"line":308},22,[310],{"type":23,"tag":121,"props":311,"children":312},{"emptyLinePlaceholder":200},[313],{"type":32,"value":203},{"type":23,"tag":121,"props":315,"children":317},{"class":123,"line":316},23,[318],{"type":23,"tag":121,"props":319,"children":320},{},[321],{"type":32,"value":322},"    content {\n",{"type":23,"tag":121,"props":324,"children":326},{"class":123,"line":325},24,[327],{"type":23,"tag":121,"props":328,"children":329},{},[330],{"type":32,"value":331},"      cidr_block     = route.value.cidr_block\n",{"type":23,"tag":121,"props":333,"children":335},{"class":123,"line":334},25,[336],{"type":23,"tag":121,"props":337,"children":338},{},[339],{"type":32,"value":340},"      gateway_id     = aws_internet_gateway.gateway.id\n",{"type":23,"tag":121,"props":342,"children":344},{"class":123,"line":343},26,[345],{"type":23,"tag":121,"props":346,"children":347},{},[348],{"type":32,"value":349},"      instance_id    = route.value.instance_id\n",{"type":23,"tag":121,"props":351,"children":353},{"class":123,"line":352},27,[354],{"type":23,"tag":121,"props":355,"children":356},{},[357],{"type":32,"value":358},"      nat_gateway_id = route.value.nat_gateway_id\n",{"type":23,"tag":121,"props":360,"children":362},{"class":123,"line":361},28,[363],{"type":23,"tag":121,"props":364,"children":365},{},[366],{"type":32,"value":367},"    }\n",{"type":23,"tag":121,"props":369,"children":371},{"class":123,"line":370},29,[372],{"type":23,"tag":121,"props":373,"children":374},{},[375],{"type":32,"value":184},{"type":23,"tag":121,"props":377,"children":379},{"class":123,"line":378},30,[380],{"type":23,"tag":121,"props":381,"children":382},{},[383],{"type":32,"value":166},{"type":23,"tag":121,"props":385,"children":387},{"class":123,"line":386},31,[388],{"type":23,"tag":121,"props":389,"children":390},{},[391],{"type":32,"value":392},"    Name = \"${var.app-name}-route-table\"\n",{"type":23,"tag":121,"props":394,"children":396},{"class":123,"line":395},32,[397],{"type":23,"tag":121,"props":398,"children":399},{},[400],{"type":32,"value":184},{"type":23,"tag":121,"props":402,"children":404},{"class":123,"line":403},33,[405],{"type":23,"tag":121,"props":406,"children":407},{},[408],{"type":32,"value":193},{"type":23,"tag":121,"props":410,"children":412},{"class":123,"line":411},34,[413],{"type":23,"tag":121,"props":414,"children":415},{},[416],{"type":32,"value":417},"resource \"aws_subnet\" \"subnet-a\" {\n",{"type":23,"tag":121,"props":419,"children":421},{"class":123,"line":420},35,[422],{"type":23,"tag":121,"props":423,"children":424},{},[425],{"type":32,"value":426},"  vpc_id                  = aws_vpc._.id\n",{"type":23,"tag":121,"props":428,"children":430},{"class":123,"line":429},36,[431],{"type":23,"tag":121,"props":432,"children":433},{},[434],{"type":32,"value":435},"  cidr_block              = \"10.0.32.0/20\"\n",{"type":23,"tag":121,"props":437,"children":439},{"class":123,"line":438},37,[440],{"type":23,"tag":121,"props":441,"children":442},{},[443],{"type":32,"value":444},"  availability_zone       = \"${var.region}a\"\n",{"type":23,"tag":121,"props":446,"children":448},{"class":123,"line":447},38,[449],{"type":23,"tag":121,"props":450,"children":451},{},[452],{"type":32,"value":453},"  map_public_ip_on_launch = true\n",{"type":23,"tag":121,"props":455,"children":457},{"class":123,"line":456},39,[458],{"type":23,"tag":121,"props":459,"children":460},{},[461],{"type":32,"value":166},{"type":23,"tag":121,"props":463,"children":465},{"class":123,"line":464},40,[466],{"type":23,"tag":121,"props":467,"children":468},{},[469],{"type":32,"value":470},"    Name = \"${var.app-name}-subnet-a\"\n",{"type":23,"tag":121,"props":472,"children":474},{"class":123,"line":473},41,[475],{"type":23,"tag":121,"props":476,"children":477},{},[478],{"type":32,"value":184},{"type":23,"tag":121,"props":480,"children":482},{"class":123,"line":481},42,[483],{"type":23,"tag":121,"props":484,"children":485},{},[486],{"type":32,"value":193},{"type":23,"tag":121,"props":488,"children":490},{"class":123,"line":489},43,[491],{"type":23,"tag":121,"props":492,"children":493},{},[494],{"type":32,"value":495}," \n",{"type":23,"tag":121,"props":497,"children":499},{"class":123,"line":498},44,[500],{"type":23,"tag":121,"props":501,"children":502},{},[503],{"type":32,"value":504},"output \"_\" {\n",{"type":23,"tag":121,"props":506,"children":508},{"class":123,"line":507},45,[509],{"type":23,"tag":121,"props":510,"children":511},{},[512],{"type":32,"value":513},"  value = {\n",{"type":23,"tag":121,"props":515,"children":517},{"class":123,"line":516},46,[518],{"type":23,"tag":121,"props":519,"children":520},{},[521],{"type":32,"value":522},"    vpc_id = aws_vpc._.id\n",{"type":23,"tag":121,"props":524,"children":526},{"class":123,"line":525},47,[527],{"type":23,"tag":121,"props":528,"children":529},{},[530],{"type":32,"value":531},"    subnet_a = aws_subnet.subnet-a.id \n",{"type":23,"tag":121,"props":533,"children":535},{"class":123,"line":534},48,[536],{"type":23,"tag":121,"props":537,"children":538},{},[539],{"type":32,"value":184},{"type":23,"tag":121,"props":541,"children":543},{"class":123,"line":542},49,[544],{"type":23,"tag":121,"props":545,"children":546},{},[547],{"type":32,"value":193},{"type":23,"tag":37,"props":549,"children":551},{"id":550},"step-2-rds-mysql-database",[552],{"type":32,"value":553},"Step 2 - RDS MySql database",{"type":23,"tag":24,"props":555,"children":556},{},[557],{"type":32,"value":558},"Now we need to define the RDS Database with the corresponding security group, note that RDS security group has a reference\nto another security group, this will allow ingress traffic from elastic beanstalk instance to the database.",{"type":23,"tag":110,"props":560,"children":562},{"className":112,"code":561,"language":114,"meta":7,"style":7},"resource \"aws_security_group\" \"rds-sg\" {\n\n  name = \"rds-sg\"\n  description = \"RDS (terraform-managed)\"\n  vpc_id = module.vpc._.vpc_id\n\n  # Only MySQL port in for elastic beanstalk instance\n  ingress {\n    from_port       = var.rds-port\n    to_port         = var.rds-port\n    protocol        = \"tcp\"\n    security_groups = [aws_security_group.eb-sg.id]\n  }\n  # Allow all outbound traffic.\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0/0\"]\n  }\n  tags = {\n    Name = \"RDS_sg\"\n  }\n}\n\nresource \"aws_db_instance\" \"rds-db\" {\n\n  name                    = var.rds-schema\n  identifier              = var.rds-identifier\n\n  allocated_storage       = 20\n  backup_retention_period = 7\n  backup_window           = \"10:46-11:16\"\n  maintenance_window      = \"Mon:00:00-Mon:03:00\"\n  engine                  = \"mysql\"\n  engine_version          = \"8.0.15\"\n  instance_class          = \"db.t2.micro\"\n  username                = var.rds-username\n  password                = var.rds-password\n  port                    = var.rds-port\n  publicly_accessible     = true\n  storage_type            = \"gp2\"\n\n  allow_major_version_upgrade  = false\n  auto_minor_version_upgrade   = true\n  performance_insights_enabled = false\n  skip_final_snapshot          = true\n  final_snapshot_identifier = \"database-${var.rds-schema}-snapshot\"\n\n  vpc_security_group_ids = [aws_security_group.rds-sg.id]\n  availability_zone         = var.rds-availability_zone\n  multi_az                  = var.rds-multi_az \n}\n",[563],{"type":23,"tag":117,"props":564,"children":565},{"__ignoreMap":7},[566,574,581,589,597,605,612,620,628,636,644,652,660,667,675,683,691,699,707,715,722,729,737,744,751,758,766,773,781,789,796,804,812,820,828,836,844,852,860,868,876,884,892,899,907,915,923,931,939,946,955,964,973],{"type":23,"tag":121,"props":567,"children":568},{"class":123,"line":124},[569],{"type":23,"tag":121,"props":570,"children":571},{},[572],{"type":32,"value":573},"resource \"aws_security_group\" \"rds-sg\" {\n",{"type":23,"tag":121,"props":575,"children":576},{"class":123,"line":133},[577],{"type":23,"tag":121,"props":578,"children":579},{"emptyLinePlaceholder":200},[580],{"type":32,"value":203},{"type":23,"tag":121,"props":582,"children":583},{"class":123,"line":142},[584],{"type":23,"tag":121,"props":585,"children":586},{},[587],{"type":32,"value":588},"  name = \"rds-sg\"\n",{"type":23,"tag":121,"props":590,"children":591},{"class":123,"line":151},[592],{"type":23,"tag":121,"props":593,"children":594},{},[595],{"type":32,"value":596},"  description = \"RDS (terraform-managed)\"\n",{"type":23,"tag":121,"props":598,"children":599},{"class":123,"line":160},[600],{"type":23,"tag":121,"props":601,"children":602},{},[603],{"type":32,"value":604},"  vpc_id = module.vpc._.vpc_id\n",{"type":23,"tag":121,"props":606,"children":607},{"class":123,"line":169},[608],{"type":23,"tag":121,"props":609,"children":610},{"emptyLinePlaceholder":200},[611],{"type":32,"value":203},{"type":23,"tag":121,"props":613,"children":614},{"class":123,"line":178},[615],{"type":23,"tag":121,"props":616,"children":617},{},[618],{"type":32,"value":619},"  # Only MySQL port in for elastic beanstalk instance\n",{"type":23,"tag":121,"props":621,"children":622},{"class":123,"line":187},[623],{"type":23,"tag":121,"props":624,"children":625},{},[626],{"type":32,"value":627},"  ingress {\n",{"type":23,"tag":121,"props":629,"children":630},{"class":123,"line":196},[631],{"type":23,"tag":121,"props":632,"children":633},{},[634],{"type":32,"value":635},"    from_port       = var.rds-port\n",{"type":23,"tag":121,"props":637,"children":638},{"class":123,"line":206},[639],{"type":23,"tag":121,"props":640,"children":641},{},[642],{"type":32,"value":643},"    to_port         = var.rds-port\n",{"type":23,"tag":121,"props":645,"children":646},{"class":123,"line":215},[647],{"type":23,"tag":121,"props":648,"children":649},{},[650],{"type":32,"value":651},"    protocol        = \"tcp\"\n",{"type":23,"tag":121,"props":653,"children":654},{"class":123,"line":224},[655],{"type":23,"tag":121,"props":656,"children":657},{},[658],{"type":32,"value":659},"    security_groups = [aws_security_group.eb-sg.id]\n",{"type":23,"tag":121,"props":661,"children":662},{"class":123,"line":232},[663],{"type":23,"tag":121,"props":664,"children":665},{},[666],{"type":32,"value":184},{"type":23,"tag":121,"props":668,"children":669},{"class":123,"line":241},[670],{"type":23,"tag":121,"props":671,"children":672},{},[673],{"type":32,"value":674},"  # Allow all outbound traffic.\n",{"type":23,"tag":121,"props":676,"children":677},{"class":123,"line":249},[678],{"type":23,"tag":121,"props":679,"children":680},{},[681],{"type":32,"value":682},"  egress {\n",{"type":23,"tag":121,"props":684,"children":685},{"class":123,"line":257},[686],{"type":23,"tag":121,"props":687,"children":688},{},[689],{"type":32,"value":690},"    from_port   = 0\n",{"type":23,"tag":121,"props":692,"children":693},{"class":123,"line":265},[694],{"type":23,"tag":121,"props":695,"children":696},{},[697],{"type":32,"value":698},"    to_port     = 0\n",{"type":23,"tag":121,"props":700,"children":701},{"class":123,"line":274},[702],{"type":23,"tag":121,"props":703,"children":704},{},[705],{"type":32,"value":706},"    protocol    = \"-1\"\n",{"type":23,"tag":121,"props":708,"children":709},{"class":123,"line":282},[710],{"type":23,"tag":121,"props":711,"children":712},{},[713],{"type":32,"value":714},"    cidr_blocks = [\"0.0.0.0/0\"]\n",{"type":23,"tag":121,"props":716,"children":717},{"class":123,"line":290},[718],{"type":23,"tag":121,"props":719,"children":720},{},[721],{"type":32,"value":184},{"type":23,"tag":121,"props":723,"children":724},{"class":123,"line":299},[725],{"type":23,"tag":121,"props":726,"children":727},{},[728],{"type":32,"value":166},{"type":23,"tag":121,"props":730,"children":731},{"class":123,"line":308},[732],{"type":23,"tag":121,"props":733,"children":734},{},[735],{"type":32,"value":736},"    Name = \"RDS_sg\"\n",{"type":23,"tag":121,"props":738,"children":739},{"class":123,"line":316},[740],{"type":23,"tag":121,"props":741,"children":742},{},[743],{"type":32,"value":184},{"type":23,"tag":121,"props":745,"children":746},{"class":123,"line":325},[747],{"type":23,"tag":121,"props":748,"children":749},{},[750],{"type":32,"value":193},{"type":23,"tag":121,"props":752,"children":753},{"class":123,"line":334},[754],{"type":23,"tag":121,"props":755,"children":756},{"emptyLinePlaceholder":200},[757],{"type":32,"value":203},{"type":23,"tag":121,"props":759,"children":760},{"class":123,"line":343},[761],{"type":23,"tag":121,"props":762,"children":763},{},[764],{"type":32,"value":765},"resource \"aws_db_instance\" \"rds-db\" {\n",{"type":23,"tag":121,"props":767,"children":768},{"class":123,"line":352},[769],{"type":23,"tag":121,"props":770,"children":771},{"emptyLinePlaceholder":200},[772],{"type":32,"value":203},{"type":23,"tag":121,"props":774,"children":775},{"class":123,"line":361},[776],{"type":23,"tag":121,"props":777,"children":778},{},[779],{"type":32,"value":780},"  name                    = var.rds-schema\n",{"type":23,"tag":121,"props":782,"children":783},{"class":123,"line":370},[784],{"type":23,"tag":121,"props":785,"children":786},{},[787],{"type":32,"value":788},"  identifier              = var.rds-identifier\n",{"type":23,"tag":121,"props":790,"children":791},{"class":123,"line":378},[792],{"type":23,"tag":121,"props":793,"children":794},{"emptyLinePlaceholder":200},[795],{"type":32,"value":203},{"type":23,"tag":121,"props":797,"children":798},{"class":123,"line":386},[799],{"type":23,"tag":121,"props":800,"children":801},{},[802],{"type":32,"value":803},"  allocated_storage       = 20\n",{"type":23,"tag":121,"props":805,"children":806},{"class":123,"line":395},[807],{"type":23,"tag":121,"props":808,"children":809},{},[810],{"type":32,"value":811},"  backup_retention_period = 7\n",{"type":23,"tag":121,"props":813,"children":814},{"class":123,"line":403},[815],{"type":23,"tag":121,"props":816,"children":817},{},[818],{"type":32,"value":819},"  backup_window           = \"10:46-11:16\"\n",{"type":23,"tag":121,"props":821,"children":822},{"class":123,"line":411},[823],{"type":23,"tag":121,"props":824,"children":825},{},[826],{"type":32,"value":827},"  maintenance_window      = \"Mon:00:00-Mon:03:00\"\n",{"type":23,"tag":121,"props":829,"children":830},{"class":123,"line":420},[831],{"type":23,"tag":121,"props":832,"children":833},{},[834],{"type":32,"value":835},"  engine                  = \"mysql\"\n",{"type":23,"tag":121,"props":837,"children":838},{"class":123,"line":429},[839],{"type":23,"tag":121,"props":840,"children":841},{},[842],{"type":32,"value":843},"  engine_version          = \"8.0.15\"\n",{"type":23,"tag":121,"props":845,"children":846},{"class":123,"line":438},[847],{"type":23,"tag":121,"props":848,"children":849},{},[850],{"type":32,"value":851},"  instance_class          = \"db.t2.micro\"\n",{"type":23,"tag":121,"props":853,"children":854},{"class":123,"line":447},[855],{"type":23,"tag":121,"props":856,"children":857},{},[858],{"type":32,"value":859},"  username                = var.rds-username\n",{"type":23,"tag":121,"props":861,"children":862},{"class":123,"line":456},[863],{"type":23,"tag":121,"props":864,"children":865},{},[866],{"type":32,"value":867},"  password                = var.rds-password\n",{"type":23,"tag":121,"props":869,"children":870},{"class":123,"line":464},[871],{"type":23,"tag":121,"props":872,"children":873},{},[874],{"type":32,"value":875},"  port                    = var.rds-port\n",{"type":23,"tag":121,"props":877,"children":878},{"class":123,"line":473},[879],{"type":23,"tag":121,"props":880,"children":881},{},[882],{"type":32,"value":883},"  publicly_accessible     = true\n",{"type":23,"tag":121,"props":885,"children":886},{"class":123,"line":481},[887],{"type":23,"tag":121,"props":888,"children":889},{},[890],{"type":32,"value":891},"  storage_type            = \"gp2\"\n",{"type":23,"tag":121,"props":893,"children":894},{"class":123,"line":489},[895],{"type":23,"tag":121,"props":896,"children":897},{"emptyLinePlaceholder":200},[898],{"type":32,"value":203},{"type":23,"tag":121,"props":900,"children":901},{"class":123,"line":498},[902],{"type":23,"tag":121,"props":903,"children":904},{},[905],{"type":32,"value":906},"  allow_major_version_upgrade  = false\n",{"type":23,"tag":121,"props":908,"children":909},{"class":123,"line":507},[910],{"type":23,"tag":121,"props":911,"children":912},{},[913],{"type":32,"value":914},"  auto_minor_version_upgrade   = true\n",{"type":23,"tag":121,"props":916,"children":917},{"class":123,"line":516},[918],{"type":23,"tag":121,"props":919,"children":920},{},[921],{"type":32,"value":922},"  performance_insights_enabled = false\n",{"type":23,"tag":121,"props":924,"children":925},{"class":123,"line":525},[926],{"type":23,"tag":121,"props":927,"children":928},{},[929],{"type":32,"value":930},"  skip_final_snapshot          = true\n",{"type":23,"tag":121,"props":932,"children":933},{"class":123,"line":534},[934],{"type":23,"tag":121,"props":935,"children":936},{},[937],{"type":32,"value":938},"  final_snapshot_identifier = \"database-${var.rds-schema}-snapshot\"\n",{"type":23,"tag":121,"props":940,"children":941},{"class":123,"line":542},[942],{"type":23,"tag":121,"props":943,"children":944},{"emptyLinePlaceholder":200},[945],{"type":32,"value":203},{"type":23,"tag":121,"props":947,"children":949},{"class":123,"line":948},50,[950],{"type":23,"tag":121,"props":951,"children":952},{},[953],{"type":32,"value":954},"  vpc_security_group_ids = [aws_security_group.rds-sg.id]\n",{"type":23,"tag":121,"props":956,"children":958},{"class":123,"line":957},51,[959],{"type":23,"tag":121,"props":960,"children":961},{},[962],{"type":32,"value":963},"  availability_zone         = var.rds-availability_zone\n",{"type":23,"tag":121,"props":965,"children":967},{"class":123,"line":966},52,[968],{"type":23,"tag":121,"props":969,"children":970},{},[971],{"type":32,"value":972},"  multi_az                  = var.rds-multi_az \n",{"type":23,"tag":121,"props":974,"children":976},{"class":123,"line":975},53,[977],{"type":23,"tag":121,"props":978,"children":979},{},[980],{"type":32,"value":193},{"type":23,"tag":37,"props":982,"children":984},{"id":983},"step-3-elastic-beanstalk",[985],{"type":32,"value":986},"Step 3 - Elastic Beanstalk",{"type":23,"tag":24,"props":988,"children":989},{},[990,992,997],{"type":32,"value":991},"Elastic Beanstalk is a great way to deploy Java applications, you only need to focus on the application. The service\ncan be configured as a ",{"type":23,"tag":28,"props":993,"children":994},{},[995],{"type":32,"value":996},"single instance or load balanced",{"type":32,"value":998},". In this example we are going to deploy single instance, but\nfor production applications is highly recommended configuring as load balanced with a minimum of 2 instances, is not\nonly about performance, with this configuration when you deploy a new version AWS will replace 1 instance at the time\nand wait to be in healthy state, this way we can achieve 0 downtime.",{"type":23,"tag":110,"props":1000,"children":1002},{"className":112,"code":1001,"language":114,"meta":7,"style":7},"resource \"aws_security_group\" \"eb-sg\" {\n  name = \"eb-sg\"\n  description = \"SecurityGroup for ElasticBeanstalk environment.\"\n  vpc_id = module.vpc._.vpc_id\n  ingress {\n    from_port = 80\n    to_port = 80\n    protocol = \"tcp\"\n    cidr_blocks = [\"0.0.0.0/0\"]\n    ipv6_cidr_blocks = [\"::/0\"]\n  }\n  ingress {\n    from_port = 587\n    to_port = 587\n    protocol = \"tcp\"\n    cidr_blocks = [\"0.0.0.0/0\"]\n    ipv6_cidr_blocks = [\"::/0\"]\n  }\n  egress {\n    from_port = 0\n    to_port = 0\n    protocol = \"-1\"\n    cidr_blocks = [\"0.0.0.0/0\"]\n  }\n  tags = {\n    Name = \"EB_sg\"\n  }\n}\n\n# ElasticBeanstalk - Application\nresource \"aws_elastic_beanstalk_application\" \"eb-application\" {\n  name = var.app-name\n  depends_on = [aws_db_instance.rds-db]\n}\n\n# ElasticBeanstalk - Environment\nresource \"aws_elastic_beanstalk_environment\" \"eb-env-prod\" {\n\n  depends_on = [aws_db_instance.rds-db]\n\n  name                = \"${var.app-name}-prod\"\n  application         = aws_elastic_beanstalk_application.eb-application.name\n  solution_stack_name = data.aws_elastic_beanstalk_solution_stack.java8.name\n  cname_prefix        = var.app-name\n\n  setting {\n    namespace = \"aws:autoscaling:launchconfiguration\"\n    name = \"InstanceType\"\n    value = \"t2.micro\"\n  }\n  setting {\n    namespace = \"aws:elasticbeanstalk:environment\"\n    name = \"EnvironmentType\"\n    value = \"SingleInstance\"\n  }\n  setting {\n    namespace = \"aws:autoscaling:launchconfiguration\"\n    name = \"IamInstanceProfile\"\n    value = \"aws-elasticbeanstalk-ec2-role\"\n  }\n  setting {\n    namespace = \"aws:autoscaling:launchconfiguration\"\n    name = \"InstanceType\"\n    value = \"t2.micro\"\n  }\n  setting {\n    namespace = \"aws:elasticbeanstalk:application:environment\"\n    name = \"SPRING_PROFILES_ACTIVE\"\n    value = \"prod\"\n  }\n  setting {\n    namespace = \"aws:elasticbeanstalk:application:environment\"\n    name = \"SPRING_DATASOURCE_URL\"\n    value = \"jdbc:mysql://${aws_db_instance.rds-db.endpoint}/${aws_db_instance.rds-db.name}?useSSL=false\"\n  }\n  setting {\n    namespace = \"aws:elasticbeanstalk:application:environment\"\n    name = \"SPRING_DATASOURCE_USERNAME\"\n    value = aws_db_instance.rds-db.username\n  }\n  setting {\n    namespace = \"aws:elasticbeanstalk:application:environment\"\n    name = \"SPRING_DATASOURCE_PASSWORD\"\n    value = aws_db_instance.rds-db.password\n  }\n  setting {\n    namespace = \"aws:autoscaling:launchconfiguration\"\n    name = \"SecurityGroups\"\n    value = aws_security_group.eb-sg.id\n  }\n  setting {\n    namespace = \"aws:ec2:vpc\"\n    name      = \"VPCId\"\n    value     = module.vpc._.vpc_id\n  }\n  setting {\n    namespace = \"aws:ec2:vpc\"\n    name      = \"Subnets\"\n    value     = module.vpc._.subnet_a\n  }\n  setting {\n    namespace = \"aws:ec2:vpc\"\n    name = \"VPCId\"\n    value = module.vpc._.vpc_id\n  }\n  setting {\n    namespace = \"aws:ec2:vpc\"\n    name = \"AssociatePublicIpAddress\"\n    value = \"true\"\n  }\n}\n",[1003],{"type":23,"tag":117,"props":1004,"children":1005},{"__ignoreMap":7},[1006,1014,1022,1030,1037,1044,1052,1060,1068,1075,1083,1090,1097,1105,1113,1120,1127,1134,1141,1148,1156,1164,1172,1179,1186,1193,1201,1208,1215,1222,1230,1238,1246,1254,1261,1268,1276,1284,1291,1298,1305,1313,1321,1329,1337,1344,1352,1360,1368,1376,1383,1390,1398,1406,1415,1423,1431,1439,1448,1457,1465,1473,1481,1489,1497,1505,1513,1522,1531,1540,1548,1556,1564,1573,1582,1590,1598,1606,1615,1624,1632,1640,1648,1657,1666,1674,1682,1690,1699,1708,1716,1724,1733,1742,1751,1759,1767,1775,1784,1793,1801,1809,1817,1826,1835,1843,1851,1859,1868,1877,1885],{"type":23,"tag":121,"props":1007,"children":1008},{"class":123,"line":124},[1009],{"type":23,"tag":121,"props":1010,"children":1011},{},[1012],{"type":32,"value":1013},"resource \"aws_security_group\" \"eb-sg\" {\n",{"type":23,"tag":121,"props":1015,"children":1016},{"class":123,"line":133},[1017],{"type":23,"tag":121,"props":1018,"children":1019},{},[1020],{"type":32,"value":1021},"  name = \"eb-sg\"\n",{"type":23,"tag":121,"props":1023,"children":1024},{"class":123,"line":142},[1025],{"type":23,"tag":121,"props":1026,"children":1027},{},[1028],{"type":32,"value":1029},"  description = \"SecurityGroup for ElasticBeanstalk environment.\"\n",{"type":23,"tag":121,"props":1031,"children":1032},{"class":123,"line":151},[1033],{"type":23,"tag":121,"props":1034,"children":1035},{},[1036],{"type":32,"value":604},{"type":23,"tag":121,"props":1038,"children":1039},{"class":123,"line":160},[1040],{"type":23,"tag":121,"props":1041,"children":1042},{},[1043],{"type":32,"value":627},{"type":23,"tag":121,"props":1045,"children":1046},{"class":123,"line":169},[1047],{"type":23,"tag":121,"props":1048,"children":1049},{},[1050],{"type":32,"value":1051},"    from_port = 80\n",{"type":23,"tag":121,"props":1053,"children":1054},{"class":123,"line":178},[1055],{"type":23,"tag":121,"props":1056,"children":1057},{},[1058],{"type":32,"value":1059},"    to_port = 80\n",{"type":23,"tag":121,"props":1061,"children":1062},{"class":123,"line":187},[1063],{"type":23,"tag":121,"props":1064,"children":1065},{},[1066],{"type":32,"value":1067},"    protocol = \"tcp\"\n",{"type":23,"tag":121,"props":1069,"children":1070},{"class":123,"line":196},[1071],{"type":23,"tag":121,"props":1072,"children":1073},{},[1074],{"type":32,"value":714},{"type":23,"tag":121,"props":1076,"children":1077},{"class":123,"line":206},[1078],{"type":23,"tag":121,"props":1079,"children":1080},{},[1081],{"type":32,"value":1082},"    ipv6_cidr_blocks = [\"::/0\"]\n",{"type":23,"tag":121,"props":1084,"children":1085},{"class":123,"line":215},[1086],{"type":23,"tag":121,"props":1087,"children":1088},{},[1089],{"type":32,"value":184},{"type":23,"tag":121,"props":1091,"children":1092},{"class":123,"line":224},[1093],{"type":23,"tag":121,"props":1094,"children":1095},{},[1096],{"type":32,"value":627},{"type":23,"tag":121,"props":1098,"children":1099},{"class":123,"line":232},[1100],{"type":23,"tag":121,"props":1101,"children":1102},{},[1103],{"type":32,"value":1104},"    from_port = 587\n",{"type":23,"tag":121,"props":1106,"children":1107},{"class":123,"line":241},[1108],{"type":23,"tag":121,"props":1109,"children":1110},{},[1111],{"type":32,"value":1112},"    to_port = 587\n",{"type":23,"tag":121,"props":1114,"children":1115},{"class":123,"line":249},[1116],{"type":23,"tag":121,"props":1117,"children":1118},{},[1119],{"type":32,"value":1067},{"type":23,"tag":121,"props":1121,"children":1122},{"class":123,"line":257},[1123],{"type":23,"tag":121,"props":1124,"children":1125},{},[1126],{"type":32,"value":714},{"type":23,"tag":121,"props":1128,"children":1129},{"class":123,"line":265},[1130],{"type":23,"tag":121,"props":1131,"children":1132},{},[1133],{"type":32,"value":1082},{"type":23,"tag":121,"props":1135,"children":1136},{"class":123,"line":274},[1137],{"type":23,"tag":121,"props":1138,"children":1139},{},[1140],{"type":32,"value":184},{"type":23,"tag":121,"props":1142,"children":1143},{"class":123,"line":282},[1144],{"type":23,"tag":121,"props":1145,"children":1146},{},[1147],{"type":32,"value":682},{"type":23,"tag":121,"props":1149,"children":1150},{"class":123,"line":290},[1151],{"type":23,"tag":121,"props":1152,"children":1153},{},[1154],{"type":32,"value":1155},"    from_port = 0\n",{"type":23,"tag":121,"props":1157,"children":1158},{"class":123,"line":299},[1159],{"type":23,"tag":121,"props":1160,"children":1161},{},[1162],{"type":32,"value":1163},"    to_port = 0\n",{"type":23,"tag":121,"props":1165,"children":1166},{"class":123,"line":308},[1167],{"type":23,"tag":121,"props":1168,"children":1169},{},[1170],{"type":32,"value":1171},"    protocol = \"-1\"\n",{"type":23,"tag":121,"props":1173,"children":1174},{"class":123,"line":316},[1175],{"type":23,"tag":121,"props":1176,"children":1177},{},[1178],{"type":32,"value":714},{"type":23,"tag":121,"props":1180,"children":1181},{"class":123,"line":325},[1182],{"type":23,"tag":121,"props":1183,"children":1184},{},[1185],{"type":32,"value":184},{"type":23,"tag":121,"props":1187,"children":1188},{"class":123,"line":334},[1189],{"type":23,"tag":121,"props":1190,"children":1191},{},[1192],{"type":32,"value":166},{"type":23,"tag":121,"props":1194,"children":1195},{"class":123,"line":343},[1196],{"type":23,"tag":121,"props":1197,"children":1198},{},[1199],{"type":32,"value":1200},"    Name = \"EB_sg\"\n",{"type":23,"tag":121,"props":1202,"children":1203},{"class":123,"line":352},[1204],{"type":23,"tag":121,"props":1205,"children":1206},{},[1207],{"type":32,"value":184},{"type":23,"tag":121,"props":1209,"children":1210},{"class":123,"line":361},[1211],{"type":23,"tag":121,"props":1212,"children":1213},{},[1214],{"type":32,"value":193},{"type":23,"tag":121,"props":1216,"children":1217},{"class":123,"line":370},[1218],{"type":23,"tag":121,"props":1219,"children":1220},{"emptyLinePlaceholder":200},[1221],{"type":32,"value":203},{"type":23,"tag":121,"props":1223,"children":1224},{"class":123,"line":378},[1225],{"type":23,"tag":121,"props":1226,"children":1227},{},[1228],{"type":32,"value":1229},"# ElasticBeanstalk - Application\n",{"type":23,"tag":121,"props":1231,"children":1232},{"class":123,"line":386},[1233],{"type":23,"tag":121,"props":1234,"children":1235},{},[1236],{"type":32,"value":1237},"resource \"aws_elastic_beanstalk_application\" \"eb-application\" {\n",{"type":23,"tag":121,"props":1239,"children":1240},{"class":123,"line":395},[1241],{"type":23,"tag":121,"props":1242,"children":1243},{},[1244],{"type":32,"value":1245},"  name = var.app-name\n",{"type":23,"tag":121,"props":1247,"children":1248},{"class":123,"line":403},[1249],{"type":23,"tag":121,"props":1250,"children":1251},{},[1252],{"type":32,"value":1253},"  depends_on = [aws_db_instance.rds-db]\n",{"type":23,"tag":121,"props":1255,"children":1256},{"class":123,"line":411},[1257],{"type":23,"tag":121,"props":1258,"children":1259},{},[1260],{"type":32,"value":193},{"type":23,"tag":121,"props":1262,"children":1263},{"class":123,"line":420},[1264],{"type":23,"tag":121,"props":1265,"children":1266},{"emptyLinePlaceholder":200},[1267],{"type":32,"value":203},{"type":23,"tag":121,"props":1269,"children":1270},{"class":123,"line":429},[1271],{"type":23,"tag":121,"props":1272,"children":1273},{},[1274],{"type":32,"value":1275},"# ElasticBeanstalk - Environment\n",{"type":23,"tag":121,"props":1277,"children":1278},{"class":123,"line":438},[1279],{"type":23,"tag":121,"props":1280,"children":1281},{},[1282],{"type":32,"value":1283},"resource \"aws_elastic_beanstalk_environment\" \"eb-env-prod\" {\n",{"type":23,"tag":121,"props":1285,"children":1286},{"class":123,"line":447},[1287],{"type":23,"tag":121,"props":1288,"children":1289},{"emptyLinePlaceholder":200},[1290],{"type":32,"value":203},{"type":23,"tag":121,"props":1292,"children":1293},{"class":123,"line":456},[1294],{"type":23,"tag":121,"props":1295,"children":1296},{},[1297],{"type":32,"value":1253},{"type":23,"tag":121,"props":1299,"children":1300},{"class":123,"line":464},[1301],{"type":23,"tag":121,"props":1302,"children":1303},{"emptyLinePlaceholder":200},[1304],{"type":32,"value":203},{"type":23,"tag":121,"props":1306,"children":1307},{"class":123,"line":473},[1308],{"type":23,"tag":121,"props":1309,"children":1310},{},[1311],{"type":32,"value":1312},"  name                = \"${var.app-name}-prod\"\n",{"type":23,"tag":121,"props":1314,"children":1315},{"class":123,"line":481},[1316],{"type":23,"tag":121,"props":1317,"children":1318},{},[1319],{"type":32,"value":1320},"  application         = aws_elastic_beanstalk_application.eb-application.name\n",{"type":23,"tag":121,"props":1322,"children":1323},{"class":123,"line":489},[1324],{"type":23,"tag":121,"props":1325,"children":1326},{},[1327],{"type":32,"value":1328},"  solution_stack_name = data.aws_elastic_beanstalk_solution_stack.java8.name\n",{"type":23,"tag":121,"props":1330,"children":1331},{"class":123,"line":498},[1332],{"type":23,"tag":121,"props":1333,"children":1334},{},[1335],{"type":32,"value":1336},"  cname_prefix        = var.app-name\n",{"type":23,"tag":121,"props":1338,"children":1339},{"class":123,"line":507},[1340],{"type":23,"tag":121,"props":1341,"children":1342},{"emptyLinePlaceholder":200},[1343],{"type":32,"value":203},{"type":23,"tag":121,"props":1345,"children":1346},{"class":123,"line":516},[1347],{"type":23,"tag":121,"props":1348,"children":1349},{},[1350],{"type":32,"value":1351},"  setting {\n",{"type":23,"tag":121,"props":1353,"children":1354},{"class":123,"line":525},[1355],{"type":23,"tag":121,"props":1356,"children":1357},{},[1358],{"type":32,"value":1359},"    namespace = \"aws:autoscaling:launchconfiguration\"\n",{"type":23,"tag":121,"props":1361,"children":1362},{"class":123,"line":534},[1363],{"type":23,"tag":121,"props":1364,"children":1365},{},[1366],{"type":32,"value":1367},"    name = \"InstanceType\"\n",{"type":23,"tag":121,"props":1369,"children":1370},{"class":123,"line":542},[1371],{"type":23,"tag":121,"props":1372,"children":1373},{},[1374],{"type":32,"value":1375},"    value = \"t2.micro\"\n",{"type":23,"tag":121,"props":1377,"children":1378},{"class":123,"line":948},[1379],{"type":23,"tag":121,"props":1380,"children":1381},{},[1382],{"type":32,"value":184},{"type":23,"tag":121,"props":1384,"children":1385},{"class":123,"line":957},[1386],{"type":23,"tag":121,"props":1387,"children":1388},{},[1389],{"type":32,"value":1351},{"type":23,"tag":121,"props":1391,"children":1392},{"class":123,"line":966},[1393],{"type":23,"tag":121,"props":1394,"children":1395},{},[1396],{"type":32,"value":1397},"    namespace = \"aws:elasticbeanstalk:environment\"\n",{"type":23,"tag":121,"props":1399,"children":1400},{"class":123,"line":975},[1401],{"type":23,"tag":121,"props":1402,"children":1403},{},[1404],{"type":32,"value":1405},"    name = \"EnvironmentType\"\n",{"type":23,"tag":121,"props":1407,"children":1409},{"class":123,"line":1408},54,[1410],{"type":23,"tag":121,"props":1411,"children":1412},{},[1413],{"type":32,"value":1414},"    value = \"SingleInstance\"\n",{"type":23,"tag":121,"props":1416,"children":1418},{"class":123,"line":1417},55,[1419],{"type":23,"tag":121,"props":1420,"children":1421},{},[1422],{"type":32,"value":184},{"type":23,"tag":121,"props":1424,"children":1426},{"class":123,"line":1425},56,[1427],{"type":23,"tag":121,"props":1428,"children":1429},{},[1430],{"type":32,"value":1351},{"type":23,"tag":121,"props":1432,"children":1434},{"class":123,"line":1433},57,[1435],{"type":23,"tag":121,"props":1436,"children":1437},{},[1438],{"type":32,"value":1359},{"type":23,"tag":121,"props":1440,"children":1442},{"class":123,"line":1441},58,[1443],{"type":23,"tag":121,"props":1444,"children":1445},{},[1446],{"type":32,"value":1447},"    name = \"IamInstanceProfile\"\n",{"type":23,"tag":121,"props":1449,"children":1451},{"class":123,"line":1450},59,[1452],{"type":23,"tag":121,"props":1453,"children":1454},{},[1455],{"type":32,"value":1456},"    value = \"aws-elasticbeanstalk-ec2-role\"\n",{"type":23,"tag":121,"props":1458,"children":1460},{"class":123,"line":1459},60,[1461],{"type":23,"tag":121,"props":1462,"children":1463},{},[1464],{"type":32,"value":184},{"type":23,"tag":121,"props":1466,"children":1468},{"class":123,"line":1467},61,[1469],{"type":23,"tag":121,"props":1470,"children":1471},{},[1472],{"type":32,"value":1351},{"type":23,"tag":121,"props":1474,"children":1476},{"class":123,"line":1475},62,[1477],{"type":23,"tag":121,"props":1478,"children":1479},{},[1480],{"type":32,"value":1359},{"type":23,"tag":121,"props":1482,"children":1484},{"class":123,"line":1483},63,[1485],{"type":23,"tag":121,"props":1486,"children":1487},{},[1488],{"type":32,"value":1367},{"type":23,"tag":121,"props":1490,"children":1492},{"class":123,"line":1491},64,[1493],{"type":23,"tag":121,"props":1494,"children":1495},{},[1496],{"type":32,"value":1375},{"type":23,"tag":121,"props":1498,"children":1500},{"class":123,"line":1499},65,[1501],{"type":23,"tag":121,"props":1502,"children":1503},{},[1504],{"type":32,"value":184},{"type":23,"tag":121,"props":1506,"children":1508},{"class":123,"line":1507},66,[1509],{"type":23,"tag":121,"props":1510,"children":1511},{},[1512],{"type":32,"value":1351},{"type":23,"tag":121,"props":1514,"children":1516},{"class":123,"line":1515},67,[1517],{"type":23,"tag":121,"props":1518,"children":1519},{},[1520],{"type":32,"value":1521},"    namespace = \"aws:elasticbeanstalk:application:environment\"\n",{"type":23,"tag":121,"props":1523,"children":1525},{"class":123,"line":1524},68,[1526],{"type":23,"tag":121,"props":1527,"children":1528},{},[1529],{"type":32,"value":1530},"    name = \"SPRING_PROFILES_ACTIVE\"\n",{"type":23,"tag":121,"props":1532,"children":1534},{"class":123,"line":1533},69,[1535],{"type":23,"tag":121,"props":1536,"children":1537},{},[1538],{"type":32,"value":1539},"    value = \"prod\"\n",{"type":23,"tag":121,"props":1541,"children":1543},{"class":123,"line":1542},70,[1544],{"type":23,"tag":121,"props":1545,"children":1546},{},[1547],{"type":32,"value":184},{"type":23,"tag":121,"props":1549,"children":1551},{"class":123,"line":1550},71,[1552],{"type":23,"tag":121,"props":1553,"children":1554},{},[1555],{"type":32,"value":1351},{"type":23,"tag":121,"props":1557,"children":1559},{"class":123,"line":1558},72,[1560],{"type":23,"tag":121,"props":1561,"children":1562},{},[1563],{"type":32,"value":1521},{"type":23,"tag":121,"props":1565,"children":1567},{"class":123,"line":1566},73,[1568],{"type":23,"tag":121,"props":1569,"children":1570},{},[1571],{"type":32,"value":1572},"    name = \"SPRING_DATASOURCE_URL\"\n",{"type":23,"tag":121,"props":1574,"children":1576},{"class":123,"line":1575},74,[1577],{"type":23,"tag":121,"props":1578,"children":1579},{},[1580],{"type":32,"value":1581},"    value = \"jdbc:mysql://${aws_db_instance.rds-db.endpoint}/${aws_db_instance.rds-db.name}?useSSL=false\"\n",{"type":23,"tag":121,"props":1583,"children":1585},{"class":123,"line":1584},75,[1586],{"type":23,"tag":121,"props":1587,"children":1588},{},[1589],{"type":32,"value":184},{"type":23,"tag":121,"props":1591,"children":1593},{"class":123,"line":1592},76,[1594],{"type":23,"tag":121,"props":1595,"children":1596},{},[1597],{"type":32,"value":1351},{"type":23,"tag":121,"props":1599,"children":1601},{"class":123,"line":1600},77,[1602],{"type":23,"tag":121,"props":1603,"children":1604},{},[1605],{"type":32,"value":1521},{"type":23,"tag":121,"props":1607,"children":1609},{"class":123,"line":1608},78,[1610],{"type":23,"tag":121,"props":1611,"children":1612},{},[1613],{"type":32,"value":1614},"    name = \"SPRING_DATASOURCE_USERNAME\"\n",{"type":23,"tag":121,"props":1616,"children":1618},{"class":123,"line":1617},79,[1619],{"type":23,"tag":121,"props":1620,"children":1621},{},[1622],{"type":32,"value":1623},"    value = aws_db_instance.rds-db.username\n",{"type":23,"tag":121,"props":1625,"children":1627},{"class":123,"line":1626},80,[1628],{"type":23,"tag":121,"props":1629,"children":1630},{},[1631],{"type":32,"value":184},{"type":23,"tag":121,"props":1633,"children":1635},{"class":123,"line":1634},81,[1636],{"type":23,"tag":121,"props":1637,"children":1638},{},[1639],{"type":32,"value":1351},{"type":23,"tag":121,"props":1641,"children":1643},{"class":123,"line":1642},82,[1644],{"type":23,"tag":121,"props":1645,"children":1646},{},[1647],{"type":32,"value":1521},{"type":23,"tag":121,"props":1649,"children":1651},{"class":123,"line":1650},83,[1652],{"type":23,"tag":121,"props":1653,"children":1654},{},[1655],{"type":32,"value":1656},"    name = \"SPRING_DATASOURCE_PASSWORD\"\n",{"type":23,"tag":121,"props":1658,"children":1660},{"class":123,"line":1659},84,[1661],{"type":23,"tag":121,"props":1662,"children":1663},{},[1664],{"type":32,"value":1665},"    value = aws_db_instance.rds-db.password\n",{"type":23,"tag":121,"props":1667,"children":1669},{"class":123,"line":1668},85,[1670],{"type":23,"tag":121,"props":1671,"children":1672},{},[1673],{"type":32,"value":184},{"type":23,"tag":121,"props":1675,"children":1677},{"class":123,"line":1676},86,[1678],{"type":23,"tag":121,"props":1679,"children":1680},{},[1681],{"type":32,"value":1351},{"type":23,"tag":121,"props":1683,"children":1685},{"class":123,"line":1684},87,[1686],{"type":23,"tag":121,"props":1687,"children":1688},{},[1689],{"type":32,"value":1359},{"type":23,"tag":121,"props":1691,"children":1693},{"class":123,"line":1692},88,[1694],{"type":23,"tag":121,"props":1695,"children":1696},{},[1697],{"type":32,"value":1698},"    name = \"SecurityGroups\"\n",{"type":23,"tag":121,"props":1700,"children":1702},{"class":123,"line":1701},89,[1703],{"type":23,"tag":121,"props":1704,"children":1705},{},[1706],{"type":32,"value":1707},"    value = aws_security_group.eb-sg.id\n",{"type":23,"tag":121,"props":1709,"children":1711},{"class":123,"line":1710},90,[1712],{"type":23,"tag":121,"props":1713,"children":1714},{},[1715],{"type":32,"value":184},{"type":23,"tag":121,"props":1717,"children":1719},{"class":123,"line":1718},91,[1720],{"type":23,"tag":121,"props":1721,"children":1722},{},[1723],{"type":32,"value":1351},{"type":23,"tag":121,"props":1725,"children":1727},{"class":123,"line":1726},92,[1728],{"type":23,"tag":121,"props":1729,"children":1730},{},[1731],{"type":32,"value":1732},"    namespace = \"aws:ec2:vpc\"\n",{"type":23,"tag":121,"props":1734,"children":1736},{"class":123,"line":1735},93,[1737],{"type":23,"tag":121,"props":1738,"children":1739},{},[1740],{"type":32,"value":1741},"    name      = \"VPCId\"\n",{"type":23,"tag":121,"props":1743,"children":1745},{"class":123,"line":1744},94,[1746],{"type":23,"tag":121,"props":1747,"children":1748},{},[1749],{"type":32,"value":1750},"    value     = module.vpc._.vpc_id\n",{"type":23,"tag":121,"props":1752,"children":1754},{"class":123,"line":1753},95,[1755],{"type":23,"tag":121,"props":1756,"children":1757},{},[1758],{"type":32,"value":184},{"type":23,"tag":121,"props":1760,"children":1762},{"class":123,"line":1761},96,[1763],{"type":23,"tag":121,"props":1764,"children":1765},{},[1766],{"type":32,"value":1351},{"type":23,"tag":121,"props":1768,"children":1770},{"class":123,"line":1769},97,[1771],{"type":23,"tag":121,"props":1772,"children":1773},{},[1774],{"type":32,"value":1732},{"type":23,"tag":121,"props":1776,"children":1778},{"class":123,"line":1777},98,[1779],{"type":23,"tag":121,"props":1780,"children":1781},{},[1782],{"type":32,"value":1783},"    name      = \"Subnets\"\n",{"type":23,"tag":121,"props":1785,"children":1787},{"class":123,"line":1786},99,[1788],{"type":23,"tag":121,"props":1789,"children":1790},{},[1791],{"type":32,"value":1792},"    value     = module.vpc._.subnet_a\n",{"type":23,"tag":121,"props":1794,"children":1796},{"class":123,"line":1795},100,[1797],{"type":23,"tag":121,"props":1798,"children":1799},{},[1800],{"type":32,"value":184},{"type":23,"tag":121,"props":1802,"children":1804},{"class":123,"line":1803},101,[1805],{"type":23,"tag":121,"props":1806,"children":1807},{},[1808],{"type":32,"value":1351},{"type":23,"tag":121,"props":1810,"children":1812},{"class":123,"line":1811},102,[1813],{"type":23,"tag":121,"props":1814,"children":1815},{},[1816],{"type":32,"value":1732},{"type":23,"tag":121,"props":1818,"children":1820},{"class":123,"line":1819},103,[1821],{"type":23,"tag":121,"props":1822,"children":1823},{},[1824],{"type":32,"value":1825},"    name = \"VPCId\"\n",{"type":23,"tag":121,"props":1827,"children":1829},{"class":123,"line":1828},104,[1830],{"type":23,"tag":121,"props":1831,"children":1832},{},[1833],{"type":32,"value":1834},"    value = module.vpc._.vpc_id\n",{"type":23,"tag":121,"props":1836,"children":1838},{"class":123,"line":1837},105,[1839],{"type":23,"tag":121,"props":1840,"children":1841},{},[1842],{"type":32,"value":184},{"type":23,"tag":121,"props":1844,"children":1846},{"class":123,"line":1845},106,[1847],{"type":23,"tag":121,"props":1848,"children":1849},{},[1850],{"type":32,"value":1351},{"type":23,"tag":121,"props":1852,"children":1854},{"class":123,"line":1853},107,[1855],{"type":23,"tag":121,"props":1856,"children":1857},{},[1858],{"type":32,"value":1732},{"type":23,"tag":121,"props":1860,"children":1862},{"class":123,"line":1861},108,[1863],{"type":23,"tag":121,"props":1864,"children":1865},{},[1866],{"type":32,"value":1867},"    name = \"AssociatePublicIpAddress\"\n",{"type":23,"tag":121,"props":1869,"children":1871},{"class":123,"line":1870},109,[1872],{"type":23,"tag":121,"props":1873,"children":1874},{},[1875],{"type":32,"value":1876},"    value = \"true\"\n",{"type":23,"tag":121,"props":1878,"children":1880},{"class":123,"line":1879},110,[1881],{"type":23,"tag":121,"props":1882,"children":1883},{},[1884],{"type":32,"value":184},{"type":23,"tag":121,"props":1886,"children":1888},{"class":123,"line":1887},111,[1889],{"type":23,"tag":121,"props":1890,"children":1891},{},[1892],{"type":32,"value":193},{"type":23,"tag":37,"props":1894,"children":1896},{"id":1895},"deploy-infrastructure",[1897],{"type":32,"value":1898},"Deploy infrastructure",{"type":23,"tag":24,"props":1900,"children":1901},{},[1902],{"type":32,"value":1903},"With terraform, only we need to do is execute the following command, providing a file with all the variables we have defined",{"type":23,"tag":110,"props":1905,"children":1909},{"className":1906,"code":1907,"language":1908,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark github-light","terraform apply -var-file=\"test.tfvars\"\n","bash",[1910],{"type":23,"tag":117,"props":1911,"children":1912},{"__ignoreMap":7},[1913],{"type":23,"tag":121,"props":1914,"children":1915},{"class":123,"line":124},[1916,1921,1927,1933],{"type":23,"tag":121,"props":1917,"children":1919},{"style":1918},"--shiki-default:#B392F0;--shiki-light:#6F42C1",[1920],{"type":32,"value":15},{"type":23,"tag":121,"props":1922,"children":1924},{"style":1923},"--shiki-default:#9ECBFF;--shiki-light:#032F62",[1925],{"type":32,"value":1926}," apply",{"type":23,"tag":121,"props":1928,"children":1930},{"style":1929},"--shiki-default:#79B8FF;--shiki-light:#005CC5",[1931],{"type":32,"value":1932}," -var-file=",{"type":23,"tag":121,"props":1934,"children":1935},{"style":1923},[1936],{"type":32,"value":1937},"\"test.tfvars\"\n",{"type":23,"tag":1939,"props":1940,"children":1941},"blockquote",{},[1942],{"type":23,"tag":24,"props":1943,"children":1944},{},[1945],{"type":23,"tag":1946,"props":1947,"children":1948},"em",{},[1949,1951],{"type":32,"value":1950},"You can find the complete code of this example in this ",{"type":23,"tag":1952,"props":1953,"children":1956},"a",{"href":1954,"target":1955},"https://github.com/JaimeDeArcos/terraform-aws-archetype","_blank",[1957],{"type":32,"value":1958},"GitHub repository",{"type":23,"tag":1960,"props":1961,"children":1962},"style",{},[1963],{"type":32,"value":1964},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}",{"title":7,"searchDepth":133,"depth":133,"links":1966},[1967,1968,1969,1970,1971],{"id":39,"depth":133,"text":42},{"id":60,"depth":133,"text":63},{"id":550,"depth":133,"text":553},{"id":983,"depth":133,"text":986},{"id":1895,"depth":133,"text":1898},"markdown","content:posts:manage-aws-infrastructure-with-terraform.md","content","posts/manage-aws-infrastructure-with-terraform.md","posts/manage-aws-infrastructure-with-terraform","md",[],[1980,1984,1988,1992,1996,2000,2004,2008,2012,2016,2020,2024,2028,2032,2036,2040,2044,2048,2051,2052,2056],{"_path":1981,"title":1982,"date":1983},"/posts/gpt-sql-integration","Implementa un analizador de consultas en lenguaje natural para bases de datos SQL con GPT","2025-01-15T11:00:00.000Z",{"_path":1985,"title":1986,"date":1987},"/posts/java-security-best-practices","Java Security Best Practices: Preventing Vulnerabilities and Threats","2024-08-15T11:00:00.000Z",{"_path":1989,"title":1990,"date":1991},"/posts/circuit-breaking-resilience","Circuit Breaking in Distributed Systems","2024-07-15T11:00:00.000Z",{"_path":1993,"title":1994,"date":1995},"/posts/maven-and-github-actions","Automating Java Builds with Maven and GitHub Actions CI/CD","2024-06-15T11:00:00.000Z",{"_path":1997,"title":1998,"date":1999},"/posts/pattern-matching-sealed-classes-java21","A Guide to Pattern Matching and Sealed Classes in Java 21","2024-05-15T11:00:00.000Z",{"_path":2001,"title":2002,"date":2003},"/posts/async-java-completable-vs-reactive","Asynchronous Programming in Java: CompletableFuture vs Reactive Streams","2024-04-15T11:00:00.000Z",{"_path":2005,"title":2006,"date":2007},"/posts/mastering-concurrency","Mastering Concurrency in Java: Threads, Executors, and Virtual Threads","2024-03-15T11:00:00.000Z",{"_path":2009,"title":2010,"date":2011},"/posts/microservices-mistakes","Common Mistakes When Developing Microservices","2024-02-15T11:00:00.000Z",{"_path":2013,"title":2014,"date":2015},"/posts/tdd-testing","Test-Driven Development (TDD) in Java with JUnit and Mockito","2024-01-15T11:00:00.000Z",{"_path":2017,"title":2018,"date":2019},"/posts/single-table-design","Single Table Design","2023-12-27T11:00:00.000Z",{"_path":2021,"title":2022,"date":2023},"/posts/java-17","Exploring Java 17's New Features","2023-10-08T11:00:00.000Z",{"_path":2025,"title":2026,"date":2027},"/posts/hexagonal-architecture","Introduction to Hexagonal Architecture","2023-10-02 18:00:00",{"_path":2029,"title":2030,"date":2031},"/posts/terraform","Unleashing the Power of Infrastructure as Code (IaC)","2023-09-24 18:00:00",{"_path":2033,"title":2034,"date":2035},"/posts/python-virtual-environments","Python Virtual Environments (venv)","2023-09-17 22:00:00",{"_path":2037,"title":2038,"date":2039},"/posts/api-first-principles","API First principles","2023-09-01 22:15:18",{"_path":2041,"title":2042,"date":2043},"/posts/how-to-configure-ssh-key-based-authentication","How To Configure SSH Key-Based Authentication","2021-02-21 03:46:12",{"_path":2045,"title":2046,"date":2047},"/posts/algorithms-binary-search-tree","Algorithms - Binary Search Tree in kotlin","2020-12-06T11:00:00.000Z",{"_path":2049,"title":2050,"date":2047},"/posts/how-to-create-a-twitter-bot","How to create a Twitter bot",{"_path":4,"title":8,"date":10},{"_path":2053,"title":2054,"date":2055},"/posts/algorithms-working-with-trees","Algorithms - Binary tree traversals in kotlin","2020-11-24T11:00:00.000Z",{"_path":2057,"title":2058,"date":2059},"/posts/playing-with-ocr-libraries","Playing with OCR libraries","2020-11-22T11:00:00.000Z",1790510065439]