├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ └── concerns │ │ └── .keep ├── assets │ ├── images │ │ ├── .keep │ │ ├── aza-none.svg │ │ ├── azc-none.svg │ │ ├── azb-none.svg │ │ ├── a-N-N.svg │ │ ├── b-N-N.svg │ │ └── c-N-N.svg │ ├── javascripts │ │ └── application.js │ └── stylesheets │ │ └── application.css ├── controllers │ ├── concerns │ │ └── .keep │ └── application_controller.rb ├── helpers │ └── application_helper.rb └── views │ ├── layouts │ └── application.html.erb │ └── application │ └── index.html.erb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep ├── controllers │ └── .keep ├── fixtures │ └── .keep ├── integration │ └── .keep └── test_helper.rb ├── .dockerignore ├── code_hash.txt ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── cdk ├── cdk.json ├── requirements.txt └── app.py ├── .gitignore ├── README.md ├── bin ├── bundle ├── rake ├── rails ├── spring └── setup ├── config ├── boot.rb ├── initializers │ ├── cookies_serializer.rb │ ├── session_store.rb │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── backtrace_silencers.rb │ ├── assets.rb │ ├── wrap_parameters.rb │ └── inflections.rb ├── environment.rb ├── routes.rb ├── database.yml ├── locales │ └── en.yml ├── secrets.yml ├── application.rb └── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── config.ru ├── kubernetes ├── ingress.yaml ├── service.yaml └── deployment.yaml ├── mu.yml ├── Rakefile ├── db └── seeds.rb ├── ecs-params.yml.template ├── docker-compose.yml ├── ecs-params.yml ├── Dockerfile.cdk ├── Dockerfile ├── copilot └── ecsdemo-frontend │ └── addons │ └── task-role.yaml ├── LICENSE ├── Gemfile ├── startup.sh ├── startup-cdk.sh └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code_hash.txt: -------------------------------------------------------------------------------- 1 | NOHASH 2 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cdk/cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "python3 app.py" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | cdk.context.* 3 | cdk.out 4 | .env 5 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS REPOSITORY IS DEPRECATED 2 | 3 | Please go here for any updates and/or changes: https://github.com/aws-containers/ecsdemo-frontend 4 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /cdk/requirements.txt: -------------------------------------------------------------------------------- 1 | aws_cdk.aws_ecs_patterns 2 | aws_cdk.aws_ec2 3 | aws_cdk.aws_ecs 4 | aws_cdk.aws_ecs_patterns 5 | aws_cdk.aws_servicediscovery 6 | aws_cdk.core 7 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_rails-example-app_session' 4 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /kubernetes/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: ecsdemo-frontend 5 | spec: 6 | backend: 7 | serviceName: ecsdemo-frontend 8 | servicePort: 80 9 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /mu.yml: -------------------------------------------------------------------------------- 1 | --- 2 | service: 3 | desiredCount: 3 4 | maxSize: 6 5 | port: 3000 6 | pathPatterns: 7 | - /* 8 | discoveryTTL: 5 9 | environment: 10 | CRYSTAL_URL: "http://ecsdemo-crystal/crystal" 11 | NODEJS_URL: "http://ecsdemo-nodejs/" 12 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /kubernetes/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: ecsdemo-frontend 5 | spec: 6 | selector: 7 | app: ecsdemo-frontend 8 | type: LoadBalancer 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 3000 13 | 14 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../../config/application', __FILE__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ExampleApp 5 | 11 | 12 | 13 | 14 | <%= yield %> 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # The priority is based upon order of creation: first created -> highest priority. 3 | # See how all your routes lay out with "rake routes". 4 | 5 | # Simple "Hello, World" page 6 | root 'application#index' 7 | 8 | # This URL is used for health checks 9 | get 'health' => 'application#health' 10 | end 11 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /ecs-params.yml.template: -------------------------------------------------------------------------------- 1 | version: 1 2 | task_definition: 3 | task_execution_role: $ecsTaskExecutionRole 4 | ecs_network_mode: awsvpc 5 | task_size: 6 | mem_limit: 0.5GB 7 | cpu_limit: 256 8 | run_params: 9 | network_configuration: 10 | awsvpc_configuration: 11 | subnets: 12 | - "$subnet_1" 13 | - "$subnet_2" 14 | - "$subnet_3" 15 | security_groups: 16 | - "$security_group" 17 | assign_public_ip: DISABLED 18 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | ecsdemo-frontend: 4 | environment: 5 | - CRYSTAL_URL=http://ecsdemo-crystal.service:3000/crystal 6 | - NODEJS_URL=http://ecsdemo-nodejs.service:3000 7 | image: brentley/ecsdemo-frontend 8 | ports: 9 | - "3000:3000" 10 | logging: 11 | driver: awslogs 12 | options: 13 | awslogs-group: ecsdemo-frontend 14 | awslogs-region: ${AWS_REGION} 15 | awslogs-stream-prefix: ecsdemo-frontend 16 | -------------------------------------------------------------------------------- /ecs-params.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | task_definition: 3 | task_execution_role: ecsTaskExecutionRole 4 | ecs_network_mode: awsvpc 5 | task_size: 6 | mem_limit: 0.5GB 7 | cpu_limit: 256 8 | run_params: 9 | network_configuration: 10 | awsvpc_configuration: 11 | subnets: 12 | - "subnet-07105dbab6f04ae7f" 13 | - "subnet-086d522cc6c273ac1" 14 | - "subnet-0519235cdff9e7013" 15 | security_groups: 16 | - "sg-0e5cd18b6fbb61668" 17 | assign_public_ip: DISABLED -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) 11 | Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } 12 | gem 'spring', match[1] 13 | require 'spring/binstub' 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require_tree . 17 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | # path to your application root. 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 6 | 7 | Dir.chdir APP_ROOT do 8 | # This script is a starting point to setup your application. 9 | # Add necessary setup steps to this file: 10 | 11 | puts "== Installing dependencies ==" 12 | system "gem install bundler --conservative" 13 | system "bundle check || bundle install" 14 | 15 | # puts "\n== Copying sample files ==" 16 | # unless File.exist?("config/database.yml") 17 | # system "cp config/database.yml.sample config/database.yml" 18 | # end 19 | 20 | puts "\n== Preparing database ==" 21 | system "bin/rake db:setup" 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system "rm -f log/*" 25 | system "rm -rf tmp/cache" 26 | 27 | puts "\n== Restarting application server ==" 28 | system "touch tmp/restart.txt" 29 | end 30 | -------------------------------------------------------------------------------- /Dockerfile.cdk: -------------------------------------------------------------------------------- 1 | FROM ruby:2.5-slim 2 | 3 | COPY Gemfile Gemfile.lock /usr/src/app/ 4 | WORKDIR /usr/src/app 5 | 6 | RUN apt-get update && apt-get -y install iproute2 curl jq libgmp3-dev ruby-dev build-essential sqlite libsqlite3-dev python3 python3-pip && \ 7 | bundle install && \ 8 | pip3 install awscli && \ 9 | apt-get autoremove -y --purge && \ 10 | apt-get remove -y --auto-remove --purge ruby-dev libgmp3-dev build-essential libsqlite3-dev && \ 11 | apt-get clean && \ 12 | rm -rvf /root/* /root/.gem* /var/cache/* 13 | 14 | COPY . /usr/src/app 15 | RUN chmod +x /usr/src/app/startup-cdk.sh 16 | 17 | # helpful when trying to update gems -> bundle update, remove the Gemfile.lock, start ruby 18 | # RUN bundle update 19 | # RUN rm -vf /usr/src/app/Gemfile.lock 20 | 21 | HEALTHCHECK --interval=10s --timeout=3s \ 22 | CMD curl -f -s http://localhost:3000/health/ || exit 1 23 | EXPOSE 3000 24 | ENTRYPOINT ["bash","/usr/src/app/startup-cdk.sh"] 25 | -------------------------------------------------------------------------------- /kubernetes/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: ecsdemo-frontend 5 | labels: 6 | app: ecsdemo-frontend 7 | namespace: default 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: ecsdemo-frontend 13 | strategy: 14 | rollingUpdate: 15 | maxSurge: 25% 16 | maxUnavailable: 25% 17 | type: RollingUpdate 18 | template: 19 | metadata: 20 | labels: 21 | app: ecsdemo-frontend 22 | spec: 23 | containers: 24 | - image: brentley/ecsdemo-frontend:latest 25 | imagePullPolicy: Always 26 | name: ecsdemo-frontend 27 | ports: 28 | - containerPort: 3000 29 | protocol: TCP 30 | env: 31 | - name: CRYSTAL_URL 32 | value: "http://ecsdemo-crystal.default.svc.cluster.local/crystal" 33 | - name: NODEJS_URL 34 | value: "http://ecsdemo-nodejs.default.svc.cluster.local/" 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # FROM ruby:2.5-slim 2 | FROM public.ecr.aws/bitnami/ruby:2.5 3 | 4 | COPY Gemfile Gemfile.lock /usr/src/app/ 5 | WORKDIR /usr/src/app 6 | 7 | RUN apt-get update && apt-get -y install iproute2 curl jq libgmp3-dev ruby-dev build-essential sqlite libsqlite3-dev python3 python3-pip && \ 8 | gem install bundler:1.17.3 && \ 9 | bundle install && \ 10 | pip3 install awscli netaddr && \ 11 | apt-get autoremove -y --purge && \ 12 | apt-get remove -y --auto-remove --purge ruby-dev libgmp3-dev build-essential libsqlite3-dev && \ 13 | apt-get clean && \ 14 | rm -rvf /root/* /root/.gem* /var/cache/* 15 | 16 | COPY . /usr/src/app 17 | RUN chmod +x /usr/src/app/startup-cdk.sh 18 | 19 | # helpful when trying to update gems -> bundle update, remove the Gemfile.lock, start ruby 20 | # RUN bundle update 21 | # RUN rm -vf /usr/src/app/Gemfile.lock 22 | 23 | HEALTHCHECK --interval=10s --timeout=3s \ 24 | CMD curl -f -s http://localhost:3000/health/ || exit 1 25 | EXPOSE 3000 26 | ENTRYPOINT ["bash","/usr/src/app/startup-cdk.sh"] 27 | -------------------------------------------------------------------------------- /copilot/ecsdemo-frontend/addons/task-role.yaml: -------------------------------------------------------------------------------- 1 | # You can use any of these parameters to create conditions or mappings in your template. 2 | Parameters: 3 | App: 4 | Type: String 5 | Description: Your application's name. 6 | Env: 7 | Type: String 8 | Description: The environment name your service, job, or workflow is being deployed to. 9 | Name: 10 | Type: String 11 | Description: The name of the service, job, or workflow being deployed. 12 | 13 | Resources: 14 | SubnetsAccessPolicy: 15 | Type: AWS::IAM::ManagedPolicy 16 | Properties: 17 | PolicyDocument: 18 | Version: 2012-10-17 19 | Statement: 20 | - Sid: EC2Actions 21 | Effect: Allow 22 | Action: 23 | - ec2:DescribeSubnets 24 | Resource: "*" 25 | 26 | Outputs: 27 | # You also need to output the IAM ManagedPolicy so that Copilot can inject it to your ECS task role. 28 | SubnetsAccessPolicyArn: 29 | Description: "The ARN of the Policy to attach to the task role." 30 | Value: !Ref SubnetsAccessPolicy 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Brent Langston 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 3007e861284142573607c2c60bc23c02bc5e2df5aa8f3966091ca4a61cf8f6c4f0819911271e83c1086ce3135056caa92b73a055f5edb721d66447addba365d1 15 | 16 | test: 17 | secret_key_base: e0159534f4f0beaf5b838aa81ad072c8e8798ebb6cdc2e1ba610060102ff6fefae02733c9c575f0fe03a2a2528467e59162677f904061be86fdad7e0510ebb73 18 | 19 | # TODO: This value should not be checked into the repo! It's only here to keep this example simple! 20 | production: 21 | secret_key_base: 3007e861284142573607c2c60bc23c02bc5e2df5aa8f3966091ca4a61cf8f6c4f0819911271e83c1086ce3135056caa92b73a055f5edb721d66447addba365d1 22 | # Secrets should be read from the environment! 23 | # secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 24 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module ExampleApp 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 17 | # config.time_zone = 'Central Time (US & Canada)' 18 | 19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 21 | # config.i18n.default_locale = :de 22 | 23 | # Do not swallow errors in after_commit/after_rollback callbacks. 24 | config.active_record.raise_in_transactional_callbacks = true 25 | 26 | # Since we run in a Docker container, always log to stdout 27 | config.logger = Logger.new(STDOUT) 28 | config.logger.level = Logger::ERROR 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | gem 'thin' 5 | 6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7 | gem 'rails', '4.2.10' 8 | # Use sqlite3 as the database for Active Record 9 | gem 'sqlite3' 10 | # Use SCSS for stylesheets 11 | gem 'sass-rails', '~> 5.0' 12 | # Use Uglifier as compressor for JavaScript assets 13 | gem 'uglifier', '>= 1.3.0' 14 | # Use CoffeeScript for .coffee assets and views 15 | gem 'coffee-rails', '~> 4.1.0' 16 | # See https://github.com/rails/execjs#readme for more supported runtimes 17 | gem 'therubyracer', platforms: :ruby 18 | 19 | gem 'activesupport' 20 | 21 | # Use jquery as the JavaScript library 22 | gem 'jquery-rails' 23 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 24 | gem 'turbolinks' 25 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 26 | gem 'jbuilder', '~> 2.0' 27 | # bundle exec rake doc:rails generates the API under doc/api. 28 | gem 'sdoc', '~> 0.4.0', group: :doc 29 | 30 | # Use ActiveModel has_secure_password 31 | # gem 'bcrypt', '~> 3.1.7' 32 | 33 | # Use Unicorn as the app server 34 | # gem 'unicorn' 35 | 36 | # Use Capistrano for deployment 37 | # gem 'capistrano-rails', group: :development 38 | 39 | group :development, :test do 40 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 | gem 'byebug' 42 | end 43 | 44 | group :development do 45 | # Access an IRB console on exception pages or by using <%= console %> in views 46 | gem 'web-console', '~> 2.0' 47 | 48 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 | gem 'spring' 50 | end 51 | 52 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | 8 | config.cache_classes = true 9 | config.static_cache_control = "public, max-age=300" 10 | config.assets.digest = true 11 | 12 | # config.cache_store = :mem_cache_store 13 | 14 | # Do not eager load code on boot. 15 | config.eager_load = true 16 | 17 | # Show full error reports and disable caching. 18 | config.consider_all_requests_local = true 19 | config.action_controller.perform_caching = true 20 | 21 | # Don't care if the mailer can't send. 22 | config.action_mailer.raise_delivery_errors = false 23 | 24 | # Print deprecation notices to the Rails logger. 25 | config.active_support.deprecation = :log 26 | 27 | # Raise an error on page load if there are pending migrations. 28 | config.active_record.migration_error = :page_load 29 | 30 | # Debug mode disables concatenation and preprocessing of assets. 31 | # This option may cause significant delays in view rendering with a large 32 | # number of complex assets. 33 | config.assets.debug = true 34 | 35 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 36 | # yet still be able to expire them through the digest params. 37 | config.assets.digest = true 38 | 39 | # Adds additional error checking when serving assets at runtime. 40 | # Checks for improperly declared sprockets dependencies. 41 | # Raises helpful error messages. 42 | config.assets.raise_runtime_errors = true 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static file server for tests with Cache-Control for performance. 16 | config.serve_static_files = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Randomize the order test cases are executed. 35 | config.active_support.test_order = :random 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | 5 | IP=$(ip route show |grep -o src.* |cut -f2 -d" ") 6 | # kubernetes sets routes differently -- so we will discover our IP differently 7 | if [[ ${IP} == "" ]]; then 8 | IP=$(hostname -i) 9 | fi 10 | 11 | SUBNET=$(echo ${IP} | cut -f1 -d.) 12 | NETWORK=$(echo ${IP} | cut -f3 -d.) 13 | 14 | case "${SUBNET}" in 15 | 10) 16 | orchestrator=ecs 17 | ;; 18 | 192) 19 | orchestrator=kubernetes 20 | ;; 21 | *) 22 | orchestrator=unknown 23 | ;; 24 | esac 25 | 26 | if [[ "${orchestrator}" == 'ecs' ]]; then 27 | case "${NETWORK}" in 28 | 100) 29 | zone=a 30 | color=Crimson 31 | ;; 32 | 101) 33 | zone=b 34 | color=CornflowerBlue 35 | ;; 36 | 102) 37 | zone=c 38 | color=LightGreen 39 | ;; 40 | *) 41 | zone=unknown 42 | color=Yellow 43 | ;; 44 | esac 45 | fi 46 | 47 | if [[ "${orchestrator}" == 'kubernetes' ]]; then 48 | if ((0<=${NETWORK} && ${NETWORK}<32)) 49 | then 50 | zone=a 51 | elif ((32<=${NETWORK} && ${NETWORK}<64)) 52 | then 53 | zone=b 54 | elif ((64<=${NETWORK} && ${NETWORK}<96)) 55 | then 56 | zone=c 57 | elif ((96<=${NETWORK} && ${NETWORK}<128)) 58 | then 59 | zone=a 60 | elif ((128<=${NETWORK} && ${NETWORK}<160)) 61 | then 62 | zone=b 63 | elif ((160<=${NETWORK})) 64 | then 65 | zone=c 66 | else 67 | zone=unknown 68 | fi 69 | fi 70 | 71 | if [[ ${orchestrator} == 'unknown' ]]; then 72 | zone=$(curl -m2 -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.availabilityZone' | grep -o .$) 73 | fi 74 | 75 | # Am I on ec2 instances? 76 | if [[ ${zone} == "unknown" ]]; then 77 | zone=$(curl -m2 -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.availabilityZone' | grep -o .$) 78 | fi 79 | 80 | # Still no luck? Perhaps we're running fargate! 81 | if [[ -z ${zone} ]]; then 82 | ip_addr=$(curl -m2 -s ${ECS_CONTAINER_METADATA_URI} | jq '.Networks[].IPv4Addresses[]') 83 | declare -a subnets=( $(aws ec2 describe-subnets | jq .Subnets[].CidrBlock| sed ':a;N;$!ba;s/\n/ /g') ) 84 | for sub in "${subnets[@]}"; do 85 | if $(ruby -e "puts(IPAddr.new($sub.to_s).include? $ip_addr.to_s)") == 'true'; then 86 | zone=$(aws ec2 describe-subnets | jq -r ".Subnets[] | select(.CidrBlock==$sub) | .AvailabilityZone" | grep -o .$) 87 | fi 88 | done 89 | fi 90 | 91 | export CODE_HASH="$(cat code_hash.txt)" 92 | export AZ="${IP} in AZ-${zone}" 93 | 94 | # exec bundle exec thin start 95 | RAILS_ENV=production rake assets:precompile 96 | exec rails s -e production -b 0.0.0.0 97 | -------------------------------------------------------------------------------- /startup-cdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | 5 | IP=$(ip route show |grep -o src.* |cut -f2 -d" ") 6 | # kubernetes sets routes differently -- so we will discover our IP differently 7 | if [[ ${IP} == "" ]]; then 8 | IP=$(hostname -i) 9 | fi 10 | SUBNET=$(echo ${IP} | cut -f1 -d.) 11 | NETWORK=$(echo ${IP} | cut -f3 -d.) 12 | 13 | case "${SUBNET}" in 14 | 10) 15 | orchestrator=ecs 16 | ;; 17 | 192) 18 | orchestrator=kubernetes 19 | ;; 20 | *) 21 | orchestrator=unknown 22 | ;; 23 | esac 24 | 25 | if [[ "${orchestrator}" == 'ecs' ]]; then 26 | case "${NETWORK}" in 27 | 100) 28 | zone=a 29 | color=Crimson 30 | ;; 31 | 101) 32 | zone=b 33 | color=CornflowerBlue 34 | ;; 35 | 102) 36 | zone=c 37 | color=LightGreen 38 | ;; 39 | *) 40 | zone=unknown 41 | color=Yellow 42 | ;; 43 | esac 44 | fi 45 | 46 | if [[ "${orchestrator}" == 'kubernetes' ]]; then 47 | if ((0<=${NETWORK} && ${NETWORK}<32)) 48 | then 49 | zone=a 50 | elif ((32<=${NETWORK} && ${NETWORK}<64)) 51 | then 52 | zone=b 53 | elif ((64<=${NETWORK} && ${NETWORK}<96)) 54 | then 55 | zone=c 56 | elif ((96<=${NETWORK} && ${NETWORK}<128)) 57 | then 58 | zone=a 59 | elif ((128<=${NETWORK} && ${NETWORK}<160)) 60 | then 61 | zone=b 62 | elif ((160<=${NETWORK})) 63 | then 64 | zone=c 65 | else 66 | zone=unknown 67 | fi 68 | fi 69 | 70 | if [[ ${orchestrator} == 'unknown' ]]; then 71 | zone=$(curl -m2 -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.availabilityZone' | grep -o .$) 72 | fi 73 | 74 | # Am I on ec2 instances? 75 | if [[ ${zone} == "unknown" ]]; then 76 | zone=$(curl -m2 -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.availabilityZone' | grep -o .$) 77 | fi 78 | 79 | # Still no luck? Perhaps we're running fargate! 80 | if [[ -z ${zone} ]]; then 81 | export AWS_DEFAULT_REGION=$REGION 82 | ip_addr=$(curl -m2 -s ${ECS_CONTAINER_METADATA_URI} | jq -r '.Networks[].IPv4Addresses[]') 83 | declare -a subnets=( $(aws ec2 describe-subnets | jq -r .Subnets[].CidrBlock| sed ':a;N;$!ba;s/\n/ /g') ) 84 | for sub in "${subnets[@]}"; do 85 | ip_match=$(echo -e "from netaddr import IPNetwork, IPAddress\nif IPAddress('$ip_addr') in IPNetwork('$sub'):\n print('true')" | python3) 86 | if [[ $ip_match == "true" ]];then 87 | zone=$(aws ec2 describe-subnets | jq -r --arg sub "$sub" '.Subnets[] | select(.CidrBlock==$sub) | .AvailabilityZone' | grep -o .$) 88 | fi 89 | done 90 | fi 91 | 92 | export CODE_HASH="$(cat code_hash.txt)" 93 | export IP 94 | export AZ="${IP} in AZ-${zone}" 95 | 96 | # exec bundle exec thin start 97 | RAILS_ENV=production rake assets:precompile 98 | exec rails s -e production -b 0.0.0.0 99 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | require 'net/http' 2 | require 'resolv' 3 | require 'uri' 4 | 5 | class ApplicationController < ActionController::Base 6 | # Prevent CSRF attacks by raising an exception. 7 | # For APIs, you may want to use :null_session instead. 8 | protect_from_forgery with: :exception 9 | 10 | # Example endpoint that calls the backend nodejs api 11 | def index 12 | begin 13 | req = Net::HTTP::Get.new(nodejs_uri.to_s) 14 | res = Net::HTTP.start(nodejs_uri.host, nodejs_uri.port, :use_ssl => nodejs_uri.scheme == 'https') {|http| 15 | http.read_timeout = 2 16 | http.open_timeout = 2 17 | http.request(req) 18 | } 19 | 20 | if res.code == '200' 21 | @text = res.body 22 | else 23 | @text = "no backend found" 24 | end 25 | 26 | rescue => e 27 | logger.error e.message 28 | @text = "no backend found" 29 | end 30 | 31 | begin 32 | crystalreq = Net::HTTP::Get.new(crystal_uri.to_s) 33 | crystalres = Net::HTTP.start(crystal_uri.host, crystal_uri.port, :use_ssl => crystal_uri.scheme == 'https') {|http| 34 | http.read_timeout = 2 35 | http.open_timeout = 2 36 | http.request(crystalreq) 37 | } 38 | 39 | if crystalres.code == '200' 40 | @crystal = crystalres.body 41 | else 42 | @crystal = "no backend found" 43 | end 44 | 45 | rescue => e 46 | logger.error e.message 47 | @crystal = "no backend found" 48 | end 49 | end 50 | 51 | # This endpoint is used for health checks. It should return a 200 OK when the app is up and ready to serve requests. 52 | def health 53 | render plain: "OK" 54 | end 55 | 56 | def crystal_uri 57 | expand_url ENV["CRYSTAL_URL"] 58 | end 59 | 60 | def nodejs_uri 61 | expand_url ENV["NODEJS_URL"] 62 | end 63 | 64 | # Resolve the SRV records for the hostname in the URL 65 | def expand_url(url) 66 | uri = URI(url) 67 | resolver = Resolv::DNS.new() 68 | 69 | # if host is relative, append the service discovery name 70 | host = uri.host.count('.') > 0 ? uri.host : "#{uri.host}.#{ENV["_SERVICE_DISCOVERY_NAME"]}" 71 | 72 | # lookup the SRV record and use if found 73 | begin 74 | srv = resolver.getresource(host, Resolv::DNS::Resource::IN::SRV) 75 | uri.host = srv.target.to_s 76 | uri.port = srv.port.to_s 77 | logger.info "uri port is #{uri.port}" 78 | if uri.port == 0 79 | uri.port = 80 80 | logger.info "uri port is now #{uri.port}" 81 | end 82 | rescue => e 83 | logger.error e.message 84 | end 85 | 86 | logger.info "expanded #{url} to #{uri}" 87 | uri 88 | end 89 | 90 | before_action :discover_availability_zone 91 | before_action :code_hash 92 | 93 | def discover_availability_zone 94 | @az = ENV["AZ"] 95 | end 96 | 97 | def code_hash 98 | @code_hash = ENV["CODE_HASH"] 99 | end 100 | 101 | def custom_header 102 | response.headers['Cache-Control'] = 'max-age=86400, public' 103 | end 104 | end 105 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like 20 | # NGINX, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | # config.serve_static_assets = true 26 | config.serve_static_files = true 27 | config.static_cache_control = "public, max-age=172800" 28 | 29 | 30 | 31 | # Compress JavaScripts and CSS. 32 | config.assets.js_compressor = :uglifier 33 | # config.assets.css_compressor = :sass 34 | 35 | # Do not fallback to assets pipeline if a precompiled asset is missed. 36 | config.assets.compile = true 37 | 38 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 39 | # yet still be able to expire them through the digest params. 40 | config.assets.digest = true 41 | 42 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 43 | 44 | # Specifies the header that your server uses for sending files. 45 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 46 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 47 | 48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 49 | # config.force_ssl = true 50 | 51 | # Use the lowest log level to ensure availability of diagnostic information 52 | # when problems arise. 53 | config.log_level = :debug 54 | 55 | # Prepend all log lines with the following tags. 56 | # config.log_tags = [ :subdomain, :uuid ] 57 | 58 | # Use a different logger for distributed setups. 59 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 60 | 61 | # Use a different cache store in production. 62 | # config.cache_store = :mem_cache_store 63 | 64 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 65 | # config.action_controller.asset_host = 'http://assets.example.com' 66 | 67 | # Ignore bad email addresses and do not raise email delivery errors. 68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 69 | # config.action_mailer.raise_delivery_errors = false 70 | 71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 72 | # the I18n.default_locale when a translation cannot be found). 73 | config.i18n.fallbacks = true 74 | 75 | # Send deprecation notices to registered listeners. 76 | config.active_support.deprecation = :notify 77 | 78 | # Use default logging formatter so that PID and timestamp are not suppressed. 79 | config.log_formatter = ::Logger::Formatter.new 80 | 81 | # Do not dump schema after migrations. 82 | config.active_record.dump_schema_after_migration = false 83 | end 84 | -------------------------------------------------------------------------------- /cdk/app.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # cdk: 1.25.0 4 | from aws_cdk import ( 5 | aws_ec2, 6 | aws_ecs, 7 | aws_ecs_patterns, 8 | aws_servicediscovery, 9 | aws_iam, 10 | core, 11 | ) 12 | 13 | from os import getenv 14 | 15 | 16 | # Creating a construct that will populate the required objects created in the platform repo such as vpc, ecs cluster, and service discovery namespace 17 | class BasePlatform(core.Construct): 18 | 19 | def __init__(self, scope: core.Construct, id: str, **kwargs): 20 | super().__init__(scope, id, **kwargs) 21 | self.environment_name = 'ecsworkshop' 22 | 23 | # The base platform stack is where the VPC was created, so all we need is the name to do a lookup and import it into this stack for use 24 | self.vpc = aws_ec2.Vpc.from_lookup( 25 | self, "VPC", 26 | vpc_name='{}-base/BaseVPC'.format(self.environment_name) 27 | ) 28 | 29 | self.sd_namespace = aws_servicediscovery.PrivateDnsNamespace.from_private_dns_namespace_attributes( 30 | self, "SDNamespace", 31 | namespace_name=core.Fn.import_value('NSNAME'), 32 | namespace_arn=core.Fn.import_value('NSARN'), 33 | namespace_id=core.Fn.import_value('NSID') 34 | ) 35 | 36 | self.ecs_cluster = aws_ecs.Cluster.from_cluster_attributes( 37 | self, "ECSCluster", 38 | cluster_name=core.Fn.import_value('ECSClusterName'), 39 | security_groups=[], 40 | vpc=self.vpc, 41 | default_cloud_map_namespace=self.sd_namespace 42 | ) 43 | 44 | self.services_sec_grp = aws_ec2.SecurityGroup.from_security_group_id( 45 | self, "ServicesSecGrp", 46 | security_group_id=core.Fn.import_value('ServicesSecGrp') 47 | ) 48 | 49 | 50 | class FrontendService(core.Stack): 51 | 52 | def __init__(self, scope: core.Stack, id: str, **kwargs): 53 | super().__init__(scope, id, **kwargs) 54 | 55 | self.base_platform = BasePlatform(self, self.stack_name) 56 | 57 | self.fargate_task_image = aws_ecs_patterns.ApplicationLoadBalancedTaskImageOptions( 58 | image=aws_ecs.ContainerImage.from_registry("adam9098/ecsdemo-frontend"), 59 | container_port=3000, 60 | environment={ 61 | "CRYSTAL_URL": "http://ecsdemo-crystal.service:3000/crystal", 62 | "NODEJS_URL": "http://ecsdemo-nodejs.service:3000", 63 | "REGION": getenv('AWS_DEFAULT_REGION') 64 | }, 65 | ) 66 | 67 | self.fargate_load_balanced_service = aws_ecs_patterns.ApplicationLoadBalancedFargateService( 68 | self, "FrontendFargateLBService", 69 | service_name='ecsdemo-frontend', 70 | cluster=self.base_platform.ecs_cluster, 71 | cpu=256, 72 | memory_limit_mib=512, 73 | desired_count=1, 74 | public_load_balancer=True, 75 | cloud_map_options=self.base_platform.sd_namespace, 76 | task_image_options=self.fargate_task_image 77 | ) 78 | 79 | self.fargate_load_balanced_service.task_definition.add_to_task_role_policy( 80 | aws_iam.PolicyStatement( 81 | actions=['ec2:DescribeSubnets'], 82 | resources=['*'] 83 | ) 84 | ) 85 | 86 | self.fargate_load_balanced_service.service.connections.allow_to( 87 | self.base_platform.services_sec_grp, 88 | port_range=aws_ec2.Port(protocol=aws_ec2.Protocol.TCP, string_representation="frontendtobackend", from_port=3000, to_port=3000) 89 | ) 90 | 91 | # Enable Service Autoscaling 92 | #self.autoscale = self.fargate_load_balanced_service.service.auto_scale_task_count( 93 | # min_capacity=1, 94 | # max_capacity=10 95 | #) 96 | 97 | #self.autoscale.scale_on_cpu_utilization( 98 | # "CPUAutoscaling", 99 | # target_utilization_percent=50, 100 | # scale_in_cooldown=core.Duration.seconds(30), 101 | # scale_out_cooldown=core.Duration.seconds(30) 102 | #) 103 | 104 | 105 | _env = core.Environment(account=getenv('AWS_ACCOUNT_ID'), region=getenv('AWS_DEFAULT_REGION')) 106 | environment = "ecsworkshop" 107 | stack_name = "{}-frontend".format(environment) 108 | app = core.App() 109 | FrontendService(app, stack_name, env=_env) 110 | app.synth() 111 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.2.10) 5 | actionpack (= 4.2.10) 6 | actionview (= 4.2.10) 7 | activejob (= 4.2.10) 8 | mail (~> 2.5, >= 2.5.4) 9 | rails-dom-testing (~> 1.0, >= 1.0.5) 10 | actionpack (4.2.10) 11 | actionview (= 4.2.10) 12 | activesupport (= 4.2.10) 13 | rack (~> 1.6) 14 | rack-test (~> 0.6.2) 15 | rails-dom-testing (~> 1.0, >= 1.0.5) 16 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 17 | actionview (4.2.10) 18 | activesupport (= 4.2.10) 19 | builder (~> 3.1) 20 | erubis (~> 2.7.0) 21 | rails-dom-testing (~> 1.0, >= 1.0.5) 22 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 23 | activejob (4.2.10) 24 | activesupport (= 4.2.10) 25 | globalid (>= 0.3.0) 26 | activemodel (4.2.10) 27 | activesupport (= 4.2.10) 28 | builder (~> 3.1) 29 | activerecord (4.2.10) 30 | activemodel (= 4.2.10) 31 | activesupport (= 4.2.10) 32 | arel (~> 6.0) 33 | activesupport (4.2.10) 34 | i18n (~> 0.7) 35 | minitest (~> 5.1) 36 | thread_safe (~> 0.3, >= 0.3.4) 37 | tzinfo (~> 1.1) 38 | arel (6.0.4) 39 | binding_of_caller (0.8.0) 40 | debug_inspector (>= 0.0.1) 41 | builder (3.2.3) 42 | byebug (11.0.1) 43 | coffee-rails (4.1.1) 44 | coffee-script (>= 2.2.0) 45 | railties (>= 4.0.0, < 5.1.x) 46 | coffee-script (2.4.1) 47 | coffee-script-source 48 | execjs 49 | coffee-script-source (1.12.2) 50 | concurrent-ruby (1.1.5) 51 | crass (1.0.5) 52 | daemons (1.3.1) 53 | debug_inspector (0.0.3) 54 | erubis (2.7.0) 55 | eventmachine (1.2.7) 56 | execjs (2.7.0) 57 | ffi (1.11.1) 58 | globalid (0.4.2) 59 | activesupport (>= 4.2.0) 60 | i18n (0.9.5) 61 | concurrent-ruby (~> 1.0) 62 | jbuilder (2.9.1) 63 | activesupport (>= 4.2.0) 64 | jquery-rails (4.3.5) 65 | rails-dom-testing (>= 1, < 3) 66 | railties (>= 4.2.0) 67 | thor (>= 0.14, < 2.0) 68 | json (1.8.6) 69 | libv8 (3.16.14.19) 70 | loofah (2.3.1) 71 | crass (~> 1.0.2) 72 | nokogiri (>= 1.5.9) 73 | mail (2.7.1) 74 | mini_mime (>= 0.1.1) 75 | mini_mime (1.0.2) 76 | mini_portile2 (2.5.0) 77 | minitest (5.11.3) 78 | nokogiri (1.11.2) 79 | mini_portile2 (~> 2.5.0) 80 | racc (~> 1.4) 81 | racc (1.5.2) 82 | rack (1.6.13) 83 | rack-test (0.6.3) 84 | rack (>= 1.0) 85 | rails (4.2.10) 86 | actionmailer (= 4.2.10) 87 | actionpack (= 4.2.10) 88 | actionview (= 4.2.10) 89 | activejob (= 4.2.10) 90 | activemodel (= 4.2.10) 91 | activerecord (= 4.2.10) 92 | activesupport (= 4.2.10) 93 | bundler (>= 1.3.0, < 2.0) 94 | railties (= 4.2.10) 95 | sprockets-rails 96 | rails-deprecated_sanitizer (1.0.3) 97 | activesupport (>= 4.2.0.alpha) 98 | rails-dom-testing (1.0.9) 99 | activesupport (>= 4.2.0, < 5.0) 100 | nokogiri (~> 1.6) 101 | rails-deprecated_sanitizer (>= 1.0.1) 102 | rails-html-sanitizer (1.2.0) 103 | loofah (~> 2.2, >= 2.2.2) 104 | railties (4.2.10) 105 | actionpack (= 4.2.10) 106 | activesupport (= 4.2.10) 107 | rake (>= 0.8.7) 108 | thor (>= 0.18.1, < 2.0) 109 | rake (12.3.3) 110 | rb-fsevent (0.10.3) 111 | rb-inotify (0.10.0) 112 | ffi (~> 1.0) 113 | rdoc (4.3.0) 114 | ref (2.0.0) 115 | sass (3.7.4) 116 | sass-listen (~> 4.0.0) 117 | sass-listen (4.0.0) 118 | rb-fsevent (~> 0.9, >= 0.9.4) 119 | rb-inotify (~> 0.9, >= 0.9.7) 120 | sass-rails (5.0.7) 121 | railties (>= 4.0.0, < 6) 122 | sass (~> 3.1) 123 | sprockets (>= 2.8, < 4.0) 124 | sprockets-rails (>= 2.0, < 4.0) 125 | tilt (>= 1.1, < 3) 126 | sdoc (0.4.2) 127 | json (~> 1.7, >= 1.7.7) 128 | rdoc (~> 4.0) 129 | spring (2.1.0) 130 | sprockets (3.7.2) 131 | concurrent-ruby (~> 1.0) 132 | rack (> 1, < 3) 133 | sprockets-rails (3.2.1) 134 | actionpack (>= 4.0) 135 | activesupport (>= 4.0) 136 | sprockets (>= 3.0.0) 137 | sqlite3 (1.3.13) 138 | therubyracer (0.12.3) 139 | libv8 (~> 3.16.14.15) 140 | ref 141 | thin (1.7.2) 142 | daemons (~> 1.0, >= 1.0.9) 143 | eventmachine (~> 1.0, >= 1.0.4) 144 | rack (>= 1, < 3) 145 | thor (0.20.3) 146 | thread_safe (0.3.6) 147 | tilt (2.0.9) 148 | turbolinks (5.2.0) 149 | turbolinks-source (~> 5.2) 150 | turbolinks-source (5.2.0) 151 | tzinfo (1.2.5) 152 | thread_safe (~> 0.1) 153 | uglifier (4.1.20) 154 | execjs (>= 0.3.0, < 3) 155 | web-console (2.3.0) 156 | activemodel (>= 4.0) 157 | binding_of_caller (>= 0.7.2) 158 | railties (>= 4.0) 159 | sprockets-rails (>= 2.0, < 4.0) 160 | 161 | PLATFORMS 162 | ruby 163 | 164 | DEPENDENCIES 165 | activesupport 166 | byebug 167 | coffee-rails (~> 4.1.0) 168 | jbuilder (~> 2.0) 169 | jquery-rails 170 | rails (= 4.2.10) 171 | sass-rails (~> 5.0) 172 | sdoc (~> 0.4.0) 173 | spring 174 | sqlite3 175 | therubyracer 176 | thin 177 | turbolinks 178 | uglifier (>= 1.3.0) 179 | web-console (~> 2.0) 180 | 181 | BUNDLED WITH 182 | 1.17.3 183 | -------------------------------------------------------------------------------- /app/views/application/index.html.erb: -------------------------------------------------------------------------------- 1 | 6 | 7 |

8 |
9 | Rails frontend: Hello! from <%= @az %> running <%= @code_hash %> 10 |
11 |

12 | 13 | <% if @text != "no backend found" %> 14 |

15 |
16 | <%= @text %> 17 |
18 |

19 | <% end %> 20 | 21 | <% if @crystal != "no backend found" %> 22 |

23 |
24 | <%= @crystal %> 25 |
26 |

27 | <% end %> 28 | 29 | <% if @az =~ /AZ-unknown/ and @text =~ /no backend found/ and @crystal =~ /no backend found/ %> 30 |

<%= image_tag "a-N-N.svg" %>

31 | <% end %> 32 | 33 | <% if @az =~ /AZ-a/ and @text =~ /no backend found/ and @crystal =~ /no backend found/ %> 34 |

<%= image_tag "a-N-N.svg" %>

35 | <% end %> 36 | <% if @az =~ /AZ-b/ and @text =~ /no backend found/ and @crystal =~ /no backend found/ %> 37 |

<%= image_tag "b-N-N.svg" %>

38 | <% end %> 39 | <% if @az =~ /AZ-c/ and @text =~ /no backend found/ and @crystal =~ /no backend found/ %> 40 |

<%= image_tag "c-N-N.svg" %>

41 | <% end %> 42 | 43 | <% if @az =~ /AZ-a/ and @text =~ /AZ-a/ and @crystal =~ /no backend found/ %> 44 |

<%= image_tag "a-a-N.svg" %>

45 | <% end %> 46 | <% if @az =~ /AZ-a/ and @text =~ /AZ-b/ and @crystal =~ /no backend found/ %> 47 |

<%= image_tag "a-b-N.svg" %>

48 | <% end %> 49 | <% if @az =~ /AZ-a/ and @text =~ /AZ-c/ and @crystal =~ /no backend found/ %> 50 |

<%= image_tag "a-c-N.svg" %>

51 | <% end %> 52 | <% if @az =~ /AZ-a/ and @text =~ /no backend found/ and @crystal =~ /AZ-a/ %> 53 |

<%= image_tag "a-N-a.svg" %>

54 | <% end %> 55 | <% if @az =~ /AZ-a/ and @text =~ /no backend found/ and @crystal =~ /AZ-b/ %> 56 |

<%= image_tag "a-N-b.svg" %>

57 | <% end %> 58 | <% if @az =~ /AZ-a/ and @text =~ /no backend found/ and @crystal =~ /AZ-c/ %> 59 |

<%= image_tag "a-N-c.svg" %>

60 | <% end %> 61 | 62 | <% if @az =~ /AZ-b/ and @text =~ /AZ-a/ and @crystal =~ /no backend found/ %> 63 |

<%= image_tag "b-a-N.svg" %>

64 | <% end %> 65 | <% if @az =~ /AZ-b/ and @text =~ /AZ-b/ and @crystal =~ /no backend found/ %> 66 |

<%= image_tag "b-b-N.svg" %>

67 | <% end %> 68 | <% if @az =~ /AZ-b/ and @text =~ /AZ-c/ and @crystal =~ /no backend found/ %> 69 |

<%= image_tag "b-c-N.svg" %>

70 | <% end %> 71 | <% if @az =~ /AZ-b/ and @text =~ /no backend found/ and @crystal =~ /AZ-a/ %> 72 |

<%= image_tag "b-N-a.svg" %>

73 | <% end %> 74 | <% if @az =~ /AZ-b/ and @text =~ /no backend found/ and @crystal =~ /AZ-b/ %> 75 |

<%= image_tag "b-N-b.svg" %>

76 | <% end %> 77 | <% if @az =~ /AZ-b/ and @text =~ /no backend found/ and @crystal =~ /AZ-c/ %> 78 |

<%= image_tag "b-N-c.svg" %>

79 | <% end %> 80 | 81 | <% if @az =~ /AZ-c/ and @text =~ /AZ-a/ and @crystal =~ /no backend found/ %> 82 |

<%= image_tag "c-a-N.svg" %>

83 | <% end %> 84 | <% if @az =~ /AZ-c/ and @text =~ /AZ-b/ and @crystal =~ /no backend found/ %> 85 |

<%= image_tag "c-b-N.svg" %>

86 | <% end %> 87 | <% if @az =~ /AZ-c/ and @text =~ /AZ-c/ and @crystal =~ /no backend found/ %> 88 |

<%= image_tag "c-c-N.svg" %>

89 | <% end %> 90 | <% if @az =~ /AZ-c/ and @text =~ /no backend found/ and @crystal =~ /AZ-a/ %> 91 |

<%= image_tag "c-N-a.svg" %>

92 | <% end %> 93 | <% if @az =~ /AZ-c/ and @text =~ /no backend found/ and @crystal =~ /AZ-b/ %> 94 |

<%= image_tag "c-N-b.svg" %>

95 | <% end %> 96 | <% if @az =~ /AZ-c/ and @text =~ /no backend found/ and @crystal =~ /AZ-c/ %> 97 |

<%= image_tag "c-N-c.svg" %>

98 | <% end %> 99 | 100 | <% if @az =~ /AZ-a/ and @text =~ /AZ-a/ and @crystal =~ /AZ-a/ %> 101 |

<%= image_tag "a-a-a.svg" %>

102 | <% end %> 103 | <% if @az =~ /AZ-a/ and @text =~ /AZ-a/ and @crystal =~ /AZ-b/ %> 104 |

<%= image_tag "a-a-b.svg" %>

105 | <% end %> 106 | <% if @az =~ /AZ-a/ and @text =~ /AZ-a/ and @crystal =~ /AZ-c/ %> 107 |

<%= image_tag "a-a-c.svg" %>

108 | <% end %> 109 | <% if @az =~ /AZ-a/ and @text =~ /AZ-b/ and @crystal =~ /AZ-a/ %> 110 |

<%= image_tag "a-b-a.svg" %>

111 | <% end %> 112 | <% if @az =~ /AZ-a/ and @text =~ /AZ-b/ and @crystal =~ /AZ-b/ %> 113 |

<%= image_tag "a-b-b.svg" %>

114 | <% end %> 115 | <% if @az =~ /AZ-a/ and @text =~ /AZ-b/ and @crystal =~ /AZ-c/ %> 116 |

<%= image_tag "a-b-c.svg" %>

117 | <% end %> 118 | <% if @az =~ /AZ-a/ and @text =~ /AZ-c/ and @crystal =~ /AZ-a/ %> 119 |

<%= image_tag "a-c-a.svg" %>

120 | <% end %> 121 | <% if @az =~ /AZ-a/ and @text =~ /AZ-c/ and @crystal =~ /AZ-b/ %> 122 |

<%= image_tag "a-c-b.svg" %>

123 | <% end %> 124 | <% if @az =~ /AZ-a/ and @text =~ /AZ-c/ and @crystal =~ /AZ-c/ %> 125 |

<%= image_tag "a-c-c.svg" %>

126 | <% end %> 127 | 128 | <% if @az =~ /AZ-b/ and @text =~ /AZ-a/ and @crystal =~ /AZ-a/ %> 129 |

<%= image_tag "b-a-a.svg" %>

130 | <% end %> 131 | <% if @az =~ /AZ-b/ and @text =~ /AZ-a/ and @crystal =~ /AZ-b/ %> 132 |

<%= image_tag "b-a-b.svg" %>

133 | <% end %> 134 | <% if @az =~ /AZ-b/ and @text =~ /AZ-a/ and @crystal =~ /AZ-c/ %> 135 |

<%= image_tag "b-a-c.svg" %>

136 | <% end %> 137 | <% if @az =~ /AZ-b/ and @text =~ /AZ-b/ and @crystal =~ /AZ-a/ %> 138 |

<%= image_tag "b-b-a.svg" %>

139 | <% end %> 140 | <% if @az =~ /AZ-b/ and @text =~ /AZ-b/ and @crystal =~ /AZ-b/ %> 141 |

<%= image_tag "b-b-b.svg" %>

142 | <% end %> 143 | <% if @az =~ /AZ-b/ and @text =~ /AZ-b/ and @crystal =~ /AZ-c/ %> 144 |

<%= image_tag "b-b-c.svg" %>

145 | <% end %> 146 | <% if @az =~ /AZ-b/ and @text =~ /AZ-c/ and @crystal =~ /AZ-a/ %> 147 |

<%= image_tag "b-c-a.svg" %>

148 | <% end %> 149 | <% if @az =~ /AZ-b/ and @text =~ /AZ-c/ and @crystal =~ /AZ-b/ %> 150 |

<%= image_tag "b-c-b.svg" %>

151 | <% end %> 152 | <% if @az =~ /AZ-b/ and @text =~ /AZ-c/ and @crystal =~ /AZ-c/ %> 153 |

<%= image_tag "b-c-c.svg" %>

154 | <% end %> 155 | 156 | <% if @az =~ /AZ-c/ and @text =~ /AZ-a/ and @crystal =~ /AZ-a/ %> 157 |

<%= image_tag "c-a-a.svg" %>

158 | <% end %> 159 | <% if @az =~ /AZ-c/ and @text =~ /AZ-a/ and @crystal =~ /AZ-b/ %> 160 |

<%= image_tag "c-a-b.svg" %>

161 | <% end %> 162 | <% if @az =~ /AZ-c/ and @text =~ /AZ-a/ and @crystal =~ /AZ-c/ %> 163 |

<%= image_tag "c-a-c.svg" %>

164 | <% end %> 165 | <% if @az =~ /AZ-c/ and @text =~ /AZ-b/ and @crystal =~ /AZ-a/ %> 166 |

<%= image_tag "c-b-a.svg" %>

167 | <% end %> 168 | <% if @az =~ /AZ-c/ and @text =~ /AZ-b/ and @crystal =~ /AZ-b/ %> 169 |

<%= image_tag "c-b-b.svg" %>

170 | <% end %> 171 | <% if @az =~ /AZ-c/ and @text =~ /AZ-b/ and @crystal =~ /AZ-c/ %> 172 |

<%= image_tag "c-b-c.svg" %>

173 | <% end %> 174 | <% if @az =~ /AZ-c/ and @text =~ /AZ-c/ and @crystal =~ /AZ-a/ %> 175 |

<%= image_tag "c-c-a.svg" %>

176 | <% end %> 177 | <% if @az =~ /AZ-c/ and @text =~ /AZ-c/ and @crystal =~ /AZ-b/ %> 178 |

<%= image_tag "c-c-b.svg" %>

179 | <% end %> 180 | <% if @az =~ /AZ-c/ and @text =~ /AZ-c/ and @crystal =~ /AZ-c/ %> 181 |

<%= image_tag "c-c-c.svg" %>

182 | <% end %> 183 | -------------------------------------------------------------------------------- /app/assets/images/aza-none.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone -------------------------------------------------------------------------------- /app/assets/images/azc-none.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone -------------------------------------------------------------------------------- /app/assets/images/azb-none.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone -------------------------------------------------------------------------------- /app/assets/images/a-N-N.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 00AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone -------------------------------------------------------------------------------- /app/assets/images/b-N-N.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 00AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone -------------------------------------------------------------------------------- /app/assets/images/c-N-N.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 00AmazonAmazonRoute 53Route 53AAFrontend ALBFrontend ALBAvailability ZoneAvailability ZoneAvailability ZoneAvailability ZoneAZAZCCAZAZAZAZBBAvailability ZoneAvailability Zone --------------------------------------------------------------------------------