jets-fs 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/bin/commit_docs.sh +26 -0
- data/.circleci/config.yml +126 -0
- data/.codebuild/README.md +68 -0
- data/.codebuild/bin/jets +3 -0
- data/.codebuild/buildspec-base.yml +14 -0
- data/.codebuild/integration.sh +72 -0
- data/.codebuild/jets.postman_collection.json +323 -0
- data/.codebuild/scripts/install-docker.sh +12 -0
- data/.codebuild/scripts/install-dynamodb-local.sh +22 -0
- data/.codebuild/scripts/install-java.sh +22 -0
- data/.codebuild/scripts/install-node.sh +4 -0
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +73 -0
- data/.github/ISSUE_TEMPLATE/documentation.md +27 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
- data/.github/ISSUE_TEMPLATE/question.md +16 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +42 -0
- data/.gitignore +24 -0
- data/.gitmodules +6 -0
- data/.python-version +1 -0
- data/.rspec +4 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +533 -0
- data/Dockerfile +16 -0
- data/Dockerfile.base +53 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +190 -0
- data/Guardfile +22 -0
- data/LICENSE.txt +22 -0
- data/Procfile +2 -0
- data/README.md +203 -0
- data/Rakefile +21 -0
- data/backers.md +16 -0
- data/bin/release +9 -0
- data/buildspec.yml +18 -0
- data/exe/jets +14 -0
- data/jets.gemspec +61 -0
- data/lib/jets.rb +71 -0
- data/lib/jets/application.rb +308 -0
- data/lib/jets/aws_info.rb +111 -0
- data/lib/jets/aws_services.rb +60 -0
- data/lib/jets/aws_services/stack_status.rb +59 -0
- data/lib/jets/booter.rb +130 -0
- data/lib/jets/builders.rb +16 -0
- data/lib/jets/builders/code_builder.rb +379 -0
- data/lib/jets/builders/code_size.rb +57 -0
- data/lib/jets/builders/gem_replacer.rb +76 -0
- data/lib/jets/builders/handler_generator.rb +172 -0
- data/lib/jets/builders/lambda_layer.rb +69 -0
- data/lib/jets/builders/md5.rb +60 -0
- data/lib/jets/builders/md5_zip.rb +61 -0
- data/lib/jets/builders/purger.rb +35 -0
- data/lib/jets/builders/rack_packager.rb +51 -0
- data/lib/jets/builders/rackup_wrappers/rackup +19 -0
- data/lib/jets/builders/rackup_wrappers/rackup.rb +7 -0
- data/lib/jets/builders/reconfigure_rails.rb +114 -0
- data/lib/jets/builders/reconfigure_rails/config/initializers/jets.rb +16 -0
- data/lib/jets/builders/ruby_packager.rb +207 -0
- data/lib/jets/builders/shim_vars.rb +5 -0
- data/lib/jets/builders/shim_vars/app.rb +78 -0
- data/lib/jets/builders/shim_vars/base.rb +25 -0
- data/lib/jets/builders/shim_vars/shared.rb +37 -0
- data/lib/jets/builders/templates/handler.rb +12 -0
- data/lib/jets/builders/tidy.rb +107 -0
- data/lib/jets/builders/util.rb +31 -0
- data/lib/jets/camelizer.rb +67 -0
- data/lib/jets/cfn.rb +6 -0
- data/lib/jets/cfn/builders.rb +20 -0
- data/lib/jets/cfn/builders/api_deployment_builder.rb +58 -0
- data/lib/jets/cfn/builders/api_gateway_builder.rb +80 -0
- data/lib/jets/cfn/builders/base_child_builder.rb +82 -0
- data/lib/jets/cfn/builders/controller_builder.rb +42 -0
- data/lib/jets/cfn/builders/function_builder.rb +14 -0
- data/lib/jets/cfn/builders/interface.rb +127 -0
- data/lib/jets/cfn/builders/job_builder.rb +14 -0
- data/lib/jets/cfn/builders/parent_builder.rb +93 -0
- data/lib/jets/cfn/builders/rule_builder.rb +24 -0
- data/lib/jets/cfn/builders/shared_builder.rb +14 -0
- data/lib/jets/cfn/ship.rb +189 -0
- data/lib/jets/cfn/status.rb +212 -0
- data/lib/jets/cfn/upload.rb +139 -0
- data/lib/jets/cli.rb +189 -0
- data/lib/jets/commands.rb +27 -0
- data/lib/jets/commands/base.rb +164 -0
- data/lib/jets/commands/build.rb +217 -0
- data/lib/jets/commands/call.rb +174 -0
- data/lib/jets/commands/call/anonymous_guesser.rb +96 -0
- data/lib/jets/commands/call/autoload_guesser.rb +112 -0
- data/lib/jets/commands/call/base_guesser.rb +33 -0
- data/lib/jets/commands/call/guesser.rb +48 -0
- data/lib/jets/commands/clean.rb +23 -0
- data/lib/jets/commands/clean/base.rb +24 -0
- data/lib/jets/commands/clean/build.rb +13 -0
- data/lib/jets/commands/clean/log.rb +107 -0
- data/lib/jets/commands/console.rb +13 -0
- data/lib/jets/commands/db.rb +15 -0
- data/lib/jets/commands/db/environment-task.rake +3 -0
- data/lib/jets/commands/db/tasks.rb +44 -0
- data/lib/jets/commands/dbconsole.rb +131 -0
- data/lib/jets/commands/delete.rb +143 -0
- data/lib/jets/commands/deploy.rb +131 -0
- data/lib/jets/commands/dynamodb.rb +22 -0
- data/lib/jets/commands/dynamodb/migrate.rb +9 -0
- data/lib/jets/commands/dynamodb/migrator.rb +36 -0
- data/lib/jets/commands/gems.rb +21 -0
- data/lib/jets/commands/help.rb +9 -0
- data/lib/jets/commands/help/build.md +6 -0
- data/lib/jets/commands/help/call.md +61 -0
- data/lib/jets/commands/help/clean/build.md +5 -0
- data/lib/jets/commands/help/clean/log.md +5 -0
- data/lib/jets/commands/help/console.md +18 -0
- data/lib/jets/commands/help/db/generate.md +8 -0
- data/lib/jets/commands/help/dbconsole.md +9 -0
- data/lib/jets/commands/help/delete.md +22 -0
- data/lib/jets/commands/help/deploy.md +32 -0
- data/lib/jets/commands/help/dynamodb/generate.md +52 -0
- data/lib/jets/commands/help/dynamodb/migrate.md +4 -0
- data/lib/jets/commands/help/gems/check.md +8 -0
- data/lib/jets/commands/help/generate.md +22 -0
- data/lib/jets/commands/help/import/rack.md +13 -0
- data/lib/jets/commands/help/import/rails.md +11 -0
- data/lib/jets/commands/help/new.md +42 -0
- data/lib/jets/commands/help/routes.md +16 -0
- data/lib/jets/commands/help/runner.md +17 -0
- data/lib/jets/commands/help/server.md +15 -0
- data/lib/jets/commands/help/status.md +14 -0
- data/lib/jets/commands/help/upgrade.md +5 -0
- data/lib/jets/commands/help/url.md +6 -0
- data/lib/jets/commands/import.rb +18 -0
- data/lib/jets/commands/import/base.rb +49 -0
- data/lib/jets/commands/import/cheatsheet.rb +35 -0
- data/lib/jets/commands/import/rack.rb +16 -0
- data/lib/jets/commands/import/rail.rb +74 -0
- data/lib/jets/commands/import/sequence.rb +90 -0
- data/lib/jets/commands/import/templates/config/database.yml +26 -0
- data/lib/jets/commands/import/templates/submodules-cheatsheet.md +89 -0
- data/lib/jets/commands/main.rb +152 -0
- data/lib/jets/commands/markdown.rb +8 -0
- data/lib/jets/commands/markdown/creator.rb +58 -0
- data/lib/jets/commands/markdown/index.rb +27 -0
- data/lib/jets/commands/markdown/page.rb +125 -0
- data/lib/jets/commands/markdown/shell.rb +11 -0
- data/lib/jets/commands/new.rb +157 -0
- data/lib/jets/commands/rake_command.rb +61 -0
- data/lib/jets/commands/rake_tasks.rb +45 -0
- data/lib/jets/commands/runner.rb +18 -0
- data/lib/jets/commands/sequence.rb +99 -0
- data/lib/jets/commands/stack_info.rb +30 -0
- data/lib/jets/commands/templates/skeleton/.gitignore +12 -0
- data/lib/jets/commands/templates/skeleton/.jetskeep +1 -0
- data/lib/jets/commands/templates/skeleton/.rspec +3 -0
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +35 -0
- data/lib/jets/commands/templates/skeleton/Procfile +7 -0
- data/lib/jets/commands/templates/skeleton/README.md +11 -0
- data/lib/jets/commands/templates/skeleton/Rakefile +2 -0
- data/lib/jets/commands/templates/skeleton/app/controllers/application_controller.rb +2 -0
- data/lib/jets/commands/templates/skeleton/app/helpers/application_helper.rb +2 -0
- data/lib/jets/commands/templates/skeleton/app/jobs/application_job.rb +4 -0
- data/lib/jets/commands/templates/skeleton/app/models/application_item.rb +2 -0
- data/lib/jets/commands/templates/skeleton/app/models/application_record.rb +3 -0
- data/lib/jets/commands/templates/skeleton/app/views/layouts/application.html.erb.tt +25 -0
- data/lib/jets/commands/templates/skeleton/config.ru +5 -0
- data/lib/jets/commands/templates/skeleton/config/application.rb.tt +66 -0
- data/lib/jets/commands/templates/skeleton/config/database.yml.tt +26 -0
- data/lib/jets/commands/templates/skeleton/config/dynamodb.yml +22 -0
- data/lib/jets/commands/templates/skeleton/config/environments/development.rb +4 -0
- data/lib/jets/commands/templates/skeleton/config/environments/production.rb +4 -0
- data/lib/jets/commands/templates/skeleton/config/routes.rb +9 -0
- data/lib/jets/commands/templates/skeleton/db/.gitkeep +0 -0
- data/lib/jets/commands/templates/skeleton/public/404.html +67 -0
- data/lib/jets/commands/templates/skeleton/public/422.html +67 -0
- data/lib/jets/commands/templates/skeleton/public/500.html +66 -0
- data/lib/jets/commands/templates/skeleton/public/favicon.ico +0 -0
- data/lib/jets/commands/templates/skeleton/public/index.html.tt +91 -0
- data/lib/jets/commands/templates/skeleton/spec/controllers/posts_controller_spec.rb +15 -0
- data/lib/jets/commands/templates/skeleton/spec/fixtures/payloads/posts-index.json +51 -0
- data/lib/jets/commands/templates/skeleton/spec/fixtures/payloads/posts-show.json +53 -0
- data/lib/jets/commands/templates/skeleton/spec/spec_helper.rb.tt +30 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/packs/application.js.tt +14 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/packs/theme.scss.tt +24 -0
- data/lib/jets/commands/templates/webpacker/app/javascript/src/jets/crud.js +87 -0
- data/lib/jets/commands/upgrade.rb +146 -0
- data/lib/jets/commands/upgrade/templates/bin/webpack +19 -0
- data/lib/jets/commands/upgrade/templates/bin/webpack-dev-server +19 -0
- data/lib/jets/commands/url.rb +68 -0
- data/lib/jets/commands/webpacker_template.rb +18 -0
- data/lib/jets/controller.rb +16 -0
- data/lib/jets/controller/base.rb +103 -0
- data/lib/jets/controller/callbacks.rb +62 -0
- data/lib/jets/controller/cookies.rb +40 -0
- data/lib/jets/controller/cookies/jar.rb +269 -0
- data/lib/jets/controller/layout.rb +17 -0
- data/lib/jets/controller/middleware.rb +5 -0
- data/lib/jets/controller/middleware/cors.rb +60 -0
- data/lib/jets/controller/middleware/local.rb +119 -0
- data/lib/jets/controller/middleware/local/api_gateway.rb +93 -0
- data/lib/jets/controller/middleware/local/mimic_aws_call.rb +38 -0
- data/lib/jets/controller/middleware/local/route_matcher.rb +97 -0
- data/lib/jets/controller/middleware/main.rb +46 -0
- data/lib/jets/controller/middleware/webpacker_setup.rb +6 -0
- data/lib/jets/controller/params.rb +87 -0
- data/lib/jets/controller/rack.rb +5 -0
- data/lib/jets/controller/rack/adapter.rb +63 -0
- data/lib/jets/controller/rack/env.rb +105 -0
- data/lib/jets/controller/redirection.rb +55 -0
- data/lib/jets/controller/rendering.rb +84 -0
- data/lib/jets/controller/rendering/rack_renderer.rb +238 -0
- data/lib/jets/controller/request.rb +29 -0
- data/lib/jets/controller/response.rb +61 -0
- data/lib/jets/core.rb +211 -0
- data/lib/jets/core_ext/kernel.rb +56 -0
- data/lib/jets/db.rb +15 -0
- data/lib/jets/dotenv.rb +39 -0
- data/lib/jets/erb.rb +51 -0
- data/lib/jets/generator.rb +41 -0
- data/lib/jets/generator/templates/erb/controller/view.html.erb +2 -0
- data/lib/jets/generator/templates/erb/scaffold/_form.html.erb +39 -0
- data/lib/jets/generator/templates/erb/scaffold/edit.html.erb +6 -0
- data/lib/jets/generator/templates/erb/scaffold/index.html.erb +29 -0
- data/lib/jets/generator/templates/erb/scaffold/new.html.erb +5 -0
- data/lib/jets/generator/templates/erb/scaffold/show.html.erb +9 -0
- data/lib/jets/generator/templates/rails/assets/javascript.js +2 -0
- data/lib/jets/generator/templates/rails/assets/stylesheet.css +4 -0
- data/lib/jets/generator/templates/rails/controller/controller.rb +13 -0
- data/lib/jets/generator/templates/rails/helper/helper.rb +4 -0
- data/lib/jets/generator/templates/rails/scaffold/scaffold.css +80 -0
- data/lib/jets/generator/templates/rails/scaffold_controller/api_controller.rb +62 -0
- data/lib/jets/generator/templates/rails/scaffold_controller/controller.rb +79 -0
- data/lib/jets/inflections.rb +32 -0
- data/lib/jets/internal/app/controllers/jets/public_controller.rb +31 -0
- data/lib/jets/internal/app/controllers/jets/rack_controller.rb +25 -0
- data/lib/jets/internal/app/functions/jets/base_path.rb +153 -0
- data/lib/jets/internal/app/jobs/jets/preheat_job.rb +62 -0
- data/lib/jets/io.rb +14 -0
- data/lib/jets/job.rb +4 -0
- data/lib/jets/job/base.rb +29 -0
- data/lib/jets/job/dsl.rb +108 -0
- data/lib/jets/klass.rb +109 -0
- data/lib/jets/lambda.rb +18 -0
- data/lib/jets/lambda/dsl.rb +384 -0
- data/lib/jets/lambda/function.rb +29 -0
- data/lib/jets/lambda/function_constructor.rb +55 -0
- data/lib/jets/lambda/functions.rb +34 -0
- data/lib/jets/lambda/task.rb +111 -0
- data/lib/jets/logger.rb +24 -0
- data/lib/jets/mega.rb +7 -0
- data/lib/jets/mega/hash_converter.rb +25 -0
- data/lib/jets/mega/request.rb +140 -0
- data/lib/jets/mega/request/source.rb +21 -0
- data/lib/jets/middleware.rb +38 -0
- data/lib/jets/middleware/configurator.rb +84 -0
- data/lib/jets/middleware/default_stack.rb +49 -0
- data/lib/jets/middleware/layer.rb +34 -0
- data/lib/jets/middleware/stack.rb +77 -0
- data/lib/jets/naming.rb +49 -0
- data/lib/jets/overrides/lambda.rb +1 -0
- data/lib/jets/overrides/lambda/marshaller.rb +31 -0
- data/lib/jets/overrides/rails.rb +4 -0
- data/lib/jets/overrides/rails/asset_tag_helper.rb +114 -0
- data/lib/jets/overrides/rails/common_methods.rb +20 -0
- data/lib/jets/overrides/rails/rendering_helper.rb +26 -0
- data/lib/jets/overrides/rails/url_helper.rb +25 -0
- data/lib/jets/poly_fun.rb +82 -0
- data/lib/jets/poly_fun/base_executor.rb +125 -0
- data/lib/jets/poly_fun/lambda_executor.rb +16 -0
- data/lib/jets/poly_fun/node_error.rb +8 -0
- data/lib/jets/poly_fun/node_executor.rb +54 -0
- data/lib/jets/poly_fun/python_error.rb +8 -0
- data/lib/jets/poly_fun/python_executor.rb +23 -0
- data/lib/jets/preheat.rb +117 -0
- data/lib/jets/processors.rb +4 -0
- data/lib/jets/processors/deducer.rb +65 -0
- data/lib/jets/processors/main_processor.rb +59 -0
- data/lib/jets/rack_server.rb +80 -0
- data/lib/jets/rdoc.rb +30 -0
- data/lib/jets/resource.rb +74 -0
- data/lib/jets/resource/api_gateway.rb +9 -0
- data/lib/jets/resource/api_gateway/base_path.rb +5 -0
- data/lib/jets/resource/api_gateway/base_path/function.rb +42 -0
- data/lib/jets/resource/api_gateway/base_path/mapping.rb +44 -0
- data/lib/jets/resource/api_gateway/base_path/role.rb +76 -0
- data/lib/jets/resource/api_gateway/cors.rb +61 -0
- data/lib/jets/resource/api_gateway/deployment.rb +78 -0
- data/lib/jets/resource/api_gateway/domain_name.rb +59 -0
- data/lib/jets/resource/api_gateway/method.rb +98 -0
- data/lib/jets/resource/api_gateway/resource.rb +78 -0
- data/lib/jets/resource/api_gateway/rest_api.rb +60 -0
- data/lib/jets/resource/api_gateway/rest_api/change_detection.rb +42 -0
- data/lib/jets/resource/api_gateway/rest_api/logical_id.rb +63 -0
- data/lib/jets/resource/api_gateway/rest_api/routes.rb +11 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change.rb +12 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/base.rb +130 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/to.rb +29 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb +39 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/collision.rb +123 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/collision/variable_exception.rb +7 -0
- data/lib/jets/resource/associated.rb +26 -0
- data/lib/jets/resource/base.rb +28 -0
- data/lib/jets/resource/child_stack.rb +7 -0
- data/lib/jets/resource/child_stack/api_deployment.rb +56 -0
- data/lib/jets/resource/child_stack/api_gateway.rb +29 -0
- data/lib/jets/resource/child_stack/app_class.rb +112 -0
- data/lib/jets/resource/child_stack/base.rb +24 -0
- data/lib/jets/resource/child_stack/shared.rb +90 -0
- data/lib/jets/resource/config.rb +4 -0
- data/lib/jets/resource/config/config_rule.rb +74 -0
- data/lib/jets/resource/config/managed_rule.rb +15 -0
- data/lib/jets/resource/events.rb +3 -0
- data/lib/jets/resource/events/rule.rb +31 -0
- data/lib/jets/resource/iam.rb +8 -0
- data/lib/jets/resource/iam/application_role.rb +27 -0
- data/lib/jets/resource/iam/base_role_definition.rb +47 -0
- data/lib/jets/resource/iam/class_role.rb +74 -0
- data/lib/jets/resource/iam/function_role.rb +54 -0
- data/lib/jets/resource/iam/managed_policy.rb +22 -0
- data/lib/jets/resource/iam/policy_document.rb +41 -0
- data/lib/jets/resource/lambda.rb +5 -0
- data/lib/jets/resource/lambda/function.rb +216 -0
- data/lib/jets/resource/lambda/function/environment.rb +61 -0
- data/lib/jets/resource/lambda/gem_layer.rb +17 -0
- data/lib/jets/resource/lambda/layer_version.rb +44 -0
- data/lib/jets/resource/permission.rb +45 -0
- data/lib/jets/resource/replacer.rb +77 -0
- data/lib/jets/resource/route53.rb +3 -0
- data/lib/jets/resource/route53/record_set.rb +70 -0
- data/lib/jets/resource/s3.rb +17 -0
- data/lib/jets/resource/sns.rb +3 -0
- data/lib/jets/resource/sqs.rb +3 -0
- data/lib/jets/resource/standardizer.rb +42 -0
- data/lib/jets/route.rb +166 -0
- data/lib/jets/router.rb +175 -0
- data/lib/jets/router/scope.rb +30 -0
- data/lib/jets/rule.rb +4 -0
- data/lib/jets/rule/base.rb +19 -0
- data/lib/jets/rule/dsl.rb +110 -0
- data/lib/jets/spec_helpers.rb +52 -0
- data/lib/jets/spec_helpers/params.rb +10 -0
- data/lib/jets/spec_helpers/request.rb +98 -0
- data/lib/jets/spec_helpers/response.rb +5 -0
- data/lib/jets/stack.rb +103 -0
- data/lib/jets/stack/builder.rb +38 -0
- data/lib/jets/stack/definition.rb +50 -0
- data/lib/jets/stack/function.rb +60 -0
- data/lib/jets/stack/main.rb +5 -0
- data/lib/jets/stack/main/dsl.rb +33 -0
- data/lib/jets/stack/main/extensions/base.rb +45 -0
- data/lib/jets/stack/main/extensions/cloudwatch.rb +19 -0
- data/lib/jets/stack/main/extensions/lambda.rb +71 -0
- data/lib/jets/stack/main/extensions/sns.rb +12 -0
- data/lib/jets/stack/main/extensions/sqs.rb +36 -0
- data/lib/jets/stack/output.rb +38 -0
- data/lib/jets/stack/output/dsl.rb +19 -0
- data/lib/jets/stack/output/lookup.rb +36 -0
- data/lib/jets/stack/parameter.rb +38 -0
- data/lib/jets/stack/parameter/dsl.rb +42 -0
- data/lib/jets/stack/resource.rb +32 -0
- data/lib/jets/stack/resource/dsl.rb +19 -0
- data/lib/jets/tmp_loader.rb +52 -0
- data/lib/jets/turbine.rb +30 -0
- data/lib/jets/turbo.rb +47 -0
- data/lib/jets/turbo/database_yaml.rb +41 -0
- data/lib/jets/turbo/project/.gitignore +12 -0
- data/lib/jets/turbo/project/.jetskeep +1 -0
- data/lib/jets/turbo/project/Gemfile +16 -0
- data/lib/jets/turbo/project/Rakefile +2 -0
- data/lib/jets/turbo/project/app/controllers/application_controller.rb +2 -0
- data/lib/jets/turbo/project/app/helpers/application_helper.rb +2 -0
- data/lib/jets/turbo/project/app/jobs/application_job.rb +4 -0
- data/lib/jets/turbo/project/config.ru +5 -0
- data/lib/jets/turbo/project/config/application.rb +4 -0
- data/lib/jets/turbo/project/config/routes.rb +4 -0
- data/lib/jets/turbo/rail.rb +113 -0
- data/lib/jets/turbo/templates/config/database.yml +26 -0
- data/lib/jets/util.rb +38 -0
- data/lib/jets/version.rb +3 -0
- data/readme/prerelease.md +6 -0
- data/readme/testing.md +60 -0
- metadata +859 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
class Jets::Cfn::Builders
|
|
2
|
+
class ApiGatewayBuilder
|
|
3
|
+
include Interface
|
|
4
|
+
include Jets::AwsServices
|
|
5
|
+
|
|
6
|
+
def initialize(options={})
|
|
7
|
+
@options = options
|
|
8
|
+
@template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# compose is an interface method
|
|
12
|
+
def compose
|
|
13
|
+
return unless @options[:templates] || @options[:stack_type] != :minimal
|
|
14
|
+
|
|
15
|
+
add_gateway_rest_api
|
|
16
|
+
add_custom_domain
|
|
17
|
+
add_gateway_routes
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# template_path is an interface method
|
|
21
|
+
def template_path
|
|
22
|
+
Jets::Naming.api_gateway_template_path
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# do not bother writing a template if routes are empty
|
|
26
|
+
def write
|
|
27
|
+
super unless Jets::Router.routes.empty?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# If the are routes in config/routes.rb add Gateway API in parent stack
|
|
31
|
+
def add_gateway_rest_api
|
|
32
|
+
rest_api = Jets::Resource::ApiGateway::RestApi.new
|
|
33
|
+
add_resource(rest_api)
|
|
34
|
+
add_outputs(rest_api.outputs)
|
|
35
|
+
|
|
36
|
+
deployment = Jets::Resource::ApiGateway::Deployment.new
|
|
37
|
+
outputs = deployment.outputs(true)
|
|
38
|
+
add_output("RestApiUrl", Value: outputs["RestApiUrl"])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def add_custom_domain
|
|
42
|
+
return unless Jets.custom_domain?
|
|
43
|
+
add_domain_name
|
|
44
|
+
add_route53_dns if Jets.config.domain.route53
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def add_domain_name
|
|
48
|
+
domain_name = Jets::Resource::ApiGateway::DomainName.new
|
|
49
|
+
add_resource(domain_name)
|
|
50
|
+
add_outputs(domain_name.outputs)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def add_route53_dns
|
|
54
|
+
dns = Jets::Resource::Route53::RecordSet.new
|
|
55
|
+
add_resource(dns)
|
|
56
|
+
add_outputs(dns.outputs)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Adds route related Resources and Outputs
|
|
60
|
+
def add_gateway_routes
|
|
61
|
+
# The routes required a Gateway Resource to contain them.
|
|
62
|
+
# TODO: Support more routes. Right now outputing all routes in 1 template will hit the 60 routes limit.
|
|
63
|
+
# Will have to either output them as a joined string or break this up to multiple templates.
|
|
64
|
+
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
|
|
65
|
+
# Outputs: Maximum number of outputs that you can declare in your AWS CloudFormation template. 60 outputs
|
|
66
|
+
# Output name: Maximum size of an output name. 255 characters.
|
|
67
|
+
#
|
|
68
|
+
# Note we must use .all_paths, not .routes here because we need to
|
|
69
|
+
# build the parent ApiGateway::Resource nodes also
|
|
70
|
+
Jets::Router.all_paths.each do |path|
|
|
71
|
+
homepage = path == ''
|
|
72
|
+
next if homepage # handled by RootResourceId output already
|
|
73
|
+
|
|
74
|
+
resource = Jets::Resource::ApiGateway::Resource.new(path, internal: true)
|
|
75
|
+
add_resource(resource)
|
|
76
|
+
add_outputs(resource.outputs)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Implements:
|
|
2
|
+
#
|
|
3
|
+
# * template_path
|
|
4
|
+
#
|
|
5
|
+
# FYI
|
|
6
|
+
#
|
|
7
|
+
# * compose implemented by the classes that include this
|
|
8
|
+
class Jets::Cfn::Builders
|
|
9
|
+
class BaseChildBuilder
|
|
10
|
+
include Interface
|
|
11
|
+
|
|
12
|
+
# The app_class is can be a controller, job or anonymous function class.
|
|
13
|
+
# IE: PostsController, HardJob
|
|
14
|
+
def initialize(app_class)
|
|
15
|
+
@app_class = app_class
|
|
16
|
+
@template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# template_path is an interface method for Interface module
|
|
20
|
+
def template_path
|
|
21
|
+
Jets::Naming.app_template_path(@app_class)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def add_common_parameters
|
|
25
|
+
common_parameters = Jets::Resource::ChildStack::AppClass.common_parameters
|
|
26
|
+
common_parameters.each do |k,_|
|
|
27
|
+
add_parameter(k, Description: k)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
depends_on_params.each do |logical_id, desc|
|
|
31
|
+
add_parameter(logical_id, Description: desc)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def depends_on_params
|
|
36
|
+
return {} unless @app_class.depends_on
|
|
37
|
+
|
|
38
|
+
params = {}
|
|
39
|
+
@app_class.depends_on.each do |shared_stack|
|
|
40
|
+
dependency = shared_stack.to_s.camelize # logical_id
|
|
41
|
+
dependency_outputs(dependency).each do |output|
|
|
42
|
+
dependency_class = dependency.to_s.classify
|
|
43
|
+
desc = "From #{dependency_class}.Outputs.#{output}"
|
|
44
|
+
# key: logical_id , value: description
|
|
45
|
+
params[output] = desc
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
params
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def dependency_outputs(dependency)
|
|
52
|
+
dependency.to_s.classify.constantize.output_keys
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def add_functions
|
|
56
|
+
add_class_iam_policy
|
|
57
|
+
@app_class.tasks.each do |task|
|
|
58
|
+
add_function(task)
|
|
59
|
+
add_function_iam_policy(task)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def add_function(task)
|
|
64
|
+
resource = Jets::Resource::Lambda::Function.new(task)
|
|
65
|
+
add_resource(resource)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def add_class_iam_policy
|
|
69
|
+
return unless @app_class.build_class_iam?
|
|
70
|
+
|
|
71
|
+
resource = Jets::Resource::Iam::ClassRole.new(@app_class)
|
|
72
|
+
add_resource(resource)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def add_function_iam_policy(task)
|
|
76
|
+
return unless task.build_function_iam?
|
|
77
|
+
|
|
78
|
+
resource = Jets::Resource::Iam::FunctionRole.new(task)
|
|
79
|
+
add_resource(resource)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Implements:
|
|
2
|
+
#
|
|
3
|
+
# compose
|
|
4
|
+
# template_path
|
|
5
|
+
#
|
|
6
|
+
class Jets::Cfn::Builders
|
|
7
|
+
class ControllerBuilder < BaseChildBuilder
|
|
8
|
+
# compose is an interface method for Interface module
|
|
9
|
+
def compose
|
|
10
|
+
add_common_parameters
|
|
11
|
+
add_api_gateway_parameters
|
|
12
|
+
add_functions
|
|
13
|
+
add_routes
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_api_gateway_parameters
|
|
17
|
+
return if Jets::Router.routes.empty?
|
|
18
|
+
|
|
19
|
+
add_parameter("RestApi", Description: "RestApi")
|
|
20
|
+
scoped_routes.each do |route|
|
|
21
|
+
resource = Jets::Resource::ApiGateway::Resource.new(route.path)
|
|
22
|
+
add_parameter(resource.logical_id, Description: resource.desc)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_routes
|
|
27
|
+
scoped_routes.each_with_index do |route, i|
|
|
28
|
+
method = Jets::Resource::ApiGateway::Method.new(route)
|
|
29
|
+
add_resource(method)
|
|
30
|
+
add_resource(method.permission)
|
|
31
|
+
add_resource(method.cors) if Jets.config.cors
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# routes scoped to this controller template.
|
|
36
|
+
def scoped_routes
|
|
37
|
+
@routes ||= Jets::Router.routes.select do |route|
|
|
38
|
+
route.controller_name == @app_class.to_s
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Implements:
|
|
2
|
+
#
|
|
3
|
+
# compose
|
|
4
|
+
# template_path
|
|
5
|
+
#
|
|
6
|
+
class Jets::Cfn::Builders
|
|
7
|
+
class FunctionBuilder < BaseChildBuilder
|
|
8
|
+
# compose is an interface method for Interface module
|
|
9
|
+
def compose
|
|
10
|
+
add_common_parameters
|
|
11
|
+
add_functions
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# The class including this module should implement these methods:
|
|
2
|
+
#
|
|
3
|
+
# * compose
|
|
4
|
+
# * template_path
|
|
5
|
+
class Jets::Cfn::Builders
|
|
6
|
+
module Interface
|
|
7
|
+
extend Memoist
|
|
8
|
+
|
|
9
|
+
def build
|
|
10
|
+
# Do not bother building or writing the template unless there are functions defined
|
|
11
|
+
return if @app_class && !@app_class.build?
|
|
12
|
+
|
|
13
|
+
compose # must be implemented by subclass
|
|
14
|
+
write
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def write
|
|
18
|
+
FileUtils.mkdir_p(File.dirname(template_path))
|
|
19
|
+
IO.write(template_path, text)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def template
|
|
23
|
+
# need the to_hash or the YAML dump has
|
|
24
|
+
# !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
25
|
+
@template.to_hash
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def text
|
|
29
|
+
text = YAML.dump(template)
|
|
30
|
+
post_process_template(text)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# post process the text so that
|
|
34
|
+
# "!Ref IamRole" => !Ref IamRole
|
|
35
|
+
# We strip the surrounding quotes
|
|
36
|
+
def post_process_template(text)
|
|
37
|
+
results = text.split("\n").map do |line|
|
|
38
|
+
if line.include?(': "!') # IE: IamRole: "!Ref IamRole",
|
|
39
|
+
# IamRole: "!Ref IamRole" => IamRole: !Ref IamRole
|
|
40
|
+
line.sub(/: "(.*)"/, ': \1')
|
|
41
|
+
elsif line.include?('- "!') # IE: - "!GetAtt Foo.Arn"
|
|
42
|
+
# IamRole: - "!GetAtt Foo.Arn" => - !GetAtt Foo.Arn
|
|
43
|
+
line.sub(/- "(.*)"/, '- \1')
|
|
44
|
+
else
|
|
45
|
+
line
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
results.join("\n") + "\n"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def add_parameters(attributes)
|
|
52
|
+
attributes.each do |name,value|
|
|
53
|
+
add_parameter(name.to_s.camelize, Description: value)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def add_parameter(name, options={})
|
|
58
|
+
defaults = { Type: "String" }
|
|
59
|
+
options = defaults.merge(options)
|
|
60
|
+
@template[:Parameters] ||= {}
|
|
61
|
+
@template[:Parameters][name.to_s.camelize] = options
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def add_outputs(attributes)
|
|
65
|
+
attributes.each do |name,value|
|
|
66
|
+
add_output(name.to_s.camelize, Value: value)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def add_output(name, options={})
|
|
71
|
+
@template[:Outputs] ||= {}
|
|
72
|
+
@template[:Outputs][name.camelize] = options
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def add_resources
|
|
76
|
+
@app_class.tasks.each do |task|
|
|
77
|
+
task.associated_resources.each do |associated|
|
|
78
|
+
resource = Jets::Resource.new(associated.definition, task.replacements)
|
|
79
|
+
add_resource(resource)
|
|
80
|
+
add_resource(resource.permission)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def add_resource(resource)
|
|
86
|
+
add_template_resource(resource.logical_id, resource.type, resource.attributes)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# The add_resource method can take an options Hash with both with either
|
|
90
|
+
# top level attributes or properties.
|
|
91
|
+
#
|
|
92
|
+
# Example:
|
|
93
|
+
#
|
|
94
|
+
# Top level options:
|
|
95
|
+
#
|
|
96
|
+
# add_template_resource("MyId", "AWS::ApiGateway::RestApi",
|
|
97
|
+
# type: "AWS::ApiGateway::RestApi",
|
|
98
|
+
# properties: {
|
|
99
|
+
# name: "my-api"
|
|
100
|
+
# },
|
|
101
|
+
# depends_on: ["AnotherResource"]
|
|
102
|
+
# )
|
|
103
|
+
#
|
|
104
|
+
# Simple options with properties only:
|
|
105
|
+
#
|
|
106
|
+
# add_template_resource("MyId", "AWS::CloudFormationStack",
|
|
107
|
+
# template_url: "template_url",
|
|
108
|
+
# parameters: {},
|
|
109
|
+
# )
|
|
110
|
+
#
|
|
111
|
+
def add_template_resource(logical_id, type, options)
|
|
112
|
+
options = Jets::Camelizer.transform(options)
|
|
113
|
+
|
|
114
|
+
attributes = if options.include?('Type')
|
|
115
|
+
base = { 'Type' => type }
|
|
116
|
+
base.merge(options) # options are top-level attributes
|
|
117
|
+
else
|
|
118
|
+
{
|
|
119
|
+
'Type' => type,
|
|
120
|
+
'Properties' => options # options are properties
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
@template['Resources'][logical_id] = attributes
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
|
|
3
|
+
class Jets::Cfn::Builders
|
|
4
|
+
class ParentBuilder
|
|
5
|
+
include Interface
|
|
6
|
+
include Jets::AwsServices
|
|
7
|
+
|
|
8
|
+
def initialize(options={})
|
|
9
|
+
@options = options
|
|
10
|
+
@template = ActiveSupport::HashWithIndifferentAccess.new(Resources: {})
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# compose is an interface method
|
|
14
|
+
def compose
|
|
15
|
+
build_minimal_resources
|
|
16
|
+
build_child_resources if full?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# template_path is an interface method
|
|
20
|
+
def template_path
|
|
21
|
+
Jets::Naming.parent_template_path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def build_minimal_resources
|
|
25
|
+
# Initial s3 bucket, used to store code zipfile and templates Jets generates
|
|
26
|
+
resource = Jets::Resource::S3.new
|
|
27
|
+
add_resource(resource)
|
|
28
|
+
add_outputs(resource.outputs)
|
|
29
|
+
|
|
30
|
+
return unless full?
|
|
31
|
+
# Add application-wide IAM policy from Jets.config.iam_role
|
|
32
|
+
resource = Jets::Resource::Iam::ApplicationRole.new
|
|
33
|
+
add_resource(resource)
|
|
34
|
+
add_outputs(resource.outputs)
|
|
35
|
+
|
|
36
|
+
return if Jets.poly_only?
|
|
37
|
+
resource = Jets::Resource::Lambda::GemLayer.new
|
|
38
|
+
add_resource(resource)
|
|
39
|
+
add_outputs(resource.outputs)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def build_child_resources
|
|
43
|
+
expression = "#{Jets::Naming.template_path_prefix}-app-*"
|
|
44
|
+
# IE: path: #{Jets.build_root}/templates/demo-dev-2-comments_controller.yml
|
|
45
|
+
Dir.glob(expression).each do |path|
|
|
46
|
+
next unless File.file?(path)
|
|
47
|
+
add_app_class_stack(path)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
expression = "#{Jets::Naming.template_path_prefix}-shared-*"
|
|
51
|
+
# IE: path: #{Jets.build_root}/templates/demo-dev-2-shared-resources.yml
|
|
52
|
+
Dir.glob(expression).each do |path|
|
|
53
|
+
next unless File.file?(path)
|
|
54
|
+
|
|
55
|
+
add_shared_resources(path)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if full? and !Jets::Router.routes.empty?
|
|
59
|
+
add_api_gateway
|
|
60
|
+
add_api_deployment
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def full?
|
|
65
|
+
@options[:templates] || @options[:stack_type] == :full
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def add_app_class_stack(path)
|
|
69
|
+
resource = Jets::Resource::ChildStack::AppClass.new(@options[:s3_bucket], path: path)
|
|
70
|
+
add_child_resources(resource)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def add_shared_resources(path)
|
|
74
|
+
resource = Jets::Resource::ChildStack::Shared.new(@options[:s3_bucket], path: path)
|
|
75
|
+
add_child_resources(resource) if resource.resources?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def add_api_gateway
|
|
79
|
+
resource = Jets::Resource::ChildStack::ApiGateway.new(@options[:s3_bucket])
|
|
80
|
+
add_child_resources(resource)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def add_api_deployment
|
|
84
|
+
resource = Jets::Resource::ChildStack::ApiDeployment.new(@options[:s3_bucket])
|
|
85
|
+
add_child_resources(resource)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def add_child_resources(resource)
|
|
89
|
+
add_resource(resource)
|
|
90
|
+
add_outputs(resource.outputs)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|