{"id":19303,"date":"2018-12-03T09:00:34","date_gmt":"2018-12-03T00:00:34","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=19303"},"modified":"2018-11-28T14:08:57","modified_gmt":"2018-11-28T05:08:57","slug":"generation-of-yaml-file","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2018\/12\/03\/generation-of-yaml-file\/","title":{"rendered":"YAML\u30d5\u30a1\u30a4\u30eb\u751f\u6210\u306e\u3042\u308c\u3053\u308c"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u6cb3\u91ce\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306f<a href=\"http:\/\/www.techscore.com\/blog\/2018\/11\/22\/techscore-advent-calendar-2018\/\">TECHSCORE Advent Calendar 2018<\/a> \u306e3\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<p>\u6700\u8fd1\u3044\u308d\u3044\u308d\u306a\u30c4\u30fc\u30eb\u3001\u4f8b\u3048\u3070CI\u3068\u304b\u3001PaaS\u3068\u304b\u3092\u89e6\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u306fYAML\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f7f\u3044\u59cb\u3081\u306e\u9803\u306f\u30b7\u30f3\u30d7\u30eb\u3060\u3063\u305f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3082\u3001\u6c17\u3065\u3051\u3070\u8a18\u8ff0\u91cf\u304c\u5897\u3048\u3066\u898b\u901a\u3057\u304c\u60aa\u304f\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001Development, Staging, Production\u306e\u305d\u308c\u305e\u308c\u3067\u4f3c\u305f\u3088\u3046\u306a\u5185\u5bb9\u3060\u3051\u3069\u3061\u3087\u3063\u3068\u3060\u3051\u9055\u3046\u3001\u3068\u3044\u3046\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u3053\u3057\u3089\u3048\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3046\u3059\u308b\u3068\u3001\u7c21\u5358\u306bYAML\u30d5\u30a1\u30a4\u30eb\u3092\u8a18\u8ff0\u3057\u305f\u3044\u3068\u304b\u3001\u3042\u308f\u3088\u304f\u3070\u5171\u901a\u5316\u3055\u308c\u305f\u90e8\u5206\u3068\u3061\u3087\u3063\u3068\u3057\u305f\u5dee\u5206\u3092\u4e0a\u624b\u304f\u7ba1\u7406\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u6b32\u6c42\u306b\u99c6\u3089\u308c\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u305d\u3046\u3044\u3063\u305f\u6c17\u6301\u3061\u3067\u8abf\u3079\u3066\u307f\u305f\u3001\u3044\u304f\u3064\u304b\u30c4\u30fc\u30eb\u3084\u65b9\u6cd5\u306a\u3069\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2 id=\"toc_1\">YAML\u306e\u30a2\u30f3\u30ab\u30fc\/\u30a8\u30a4\u30ea\u30a2\u30b9\u306e\u6a5f\u80fd<\/h2>\n<p>YAML\u306b\u306f\u3082\u3068\u3082\u3068\u30a2\u30f3\u30ab\u30fc\u3068\u30a8\u30a4\u30ea\u30a2\u30b9\u306e\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u540c\u3058\u8a18\u8ff0\u3092\u907f\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"sample.yaml\" >user1: &user1\n  id: \"001\"\n  name: taro\n  live_in: osaka\n\nuser2: &user2\n  id: \"002\"\n  name: hanako\n  live_in: tokyo\n\nuser3: &user3\n  id: \"003\"\n  name: jiro\n  live_in: hokkaido\n\ngroup1:\n  - *user1\n  - *user2\n\ngroup2:\n  - *user2\n  - *user3<\/pre>\n<p>\u3053\u308c\u3092\u30d1\u30fc\u30b9\u3057\u305f\u7d50\u679c group1, group2 \u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"output.yaml\" >group1: \n  - \n    id: \"001\"\n    live_in: osaka\n    name: taro\n  - \n    id: \"002\"\n    live_in: tokyo\n    name: hanako\ngroup2: \n  - \n    id: \"002\"\n    live_in: tokyo\n    name: hanako\n  - \n    id: \"003\"\n    live_in: hokkaido\n    name: jiro<\/pre>\n<p>\u30b5\u30f3\u30d7\u30eb\u304c\u5b9f\u7528\u7684\u3067\u306f\u306a\u3044\u3067\u3059\u304c\u3001\u96f0\u56f2\u6c17\u306f\u308f\u304b\u3063\u3066\u3044\u305f\u3060\u3051\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><strong>Pros<\/strong>: YAML\u306e\u4ed5\u69d8\u306b\u6e96\u62e0\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u591a\u304f\u306e\u30c4\u30fc\u30eb\u3067\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\uff08\u306f\u305a\uff09<br \/>\n<strong>Cons<\/strong>: \u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u307e\u305f\u304c\u3063\u305f\u5171\u901a\u5316\u306f\u3067\u304d\u306a\u3044<\/p>\n<p>\u6a19\u6e96\u306e\u4ed5\u69d8\u306a\u306e\u3067\u304a\u305d\u3089\u304f\u305f\u3044\u3066\u3044\u306e\u30c4\u30fc\u30eb\u3067\u306f\u4f7f\u3048\u308b\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001AWS\u306eCloudFormation\u3067\u306f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u306a\u3044\u307f\u305f\u3044\u3067\u3059\u3002\u307e\u305f\u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u307e\u305f\u304c\u3063\u3066\u5171\u901a\u5316\u3067\u304d\u306a\u3044\u3068\u3044\u3046\u306e\u3082\u3061\u3087\u3063\u3068\u7269\u8db3\u308a\u306a\u3055\u304c\u3042\u308a\u307e\u3059\u306d\u3002<\/p>\n<h3 id=\"toc_2\">\u53c2\u8003<\/h3>\n<ul>\n<li><a href=\"https:\/\/magazine.rubyist.net\/articles\/0009\/0009-YAML.html#%E3%82%A2%E3%83%B3%E3%82%AB%E3%83%BC%E3%81%A8%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9\">\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u305f\u3081\u306e YAML \u5165\u9580 (\u521d\u7d1a\u7de8) \u30a2\u30f3\u30ab\u30fc\u3068\u30a8\u30a4\u30ea\u30a2\u30b9<\/a><\/li>\n<li> <a href=\"https:\/\/dev.classmethod.jp\/server-side\/ansible\/refactoring_ansible_yaml_using_alias_and_anchor\/\">YAML\u306e\u30a8\u30a4\u30ea\u30a2\u30b9\u3067Ansible\u30d5\u30a1\u30a4\u30eb\u306e\u91cd\u8907\u3092\u6e1b\u3089\u3059 \uff5c DevelopersIO<\/a><\/li>\n<li><a href=\"https:\/\/ohbarye.hatenablog.jp\/entry\/2018\/01\/22\/232921\">YAML\u306eAnchor\u3068Alias\u3092\u4f7f\u3063\u3066config\u3092DRY\u306b\u66f8\u304f - valid,invalid<\/a><\/li>\n<\/ul>\n<h2 id=\"toc_3\">\u4f7f\u7528\u3059\u308b\u30c4\u30fc\u30eb\u3067\u306e\u62e1\u5f35\u6a5f\u80fd<\/h2>\n<p>\u30c4\u30fc\u30eb\u306b\u3088\u3063\u3066\u306f\u3001\u5171\u901a\u5316\u306e\u305f\u3081\u306eInclude\u3084Template\u306e\u6a5f\u80fd\u3001\u5b9f\u884c\u6642\u306b\u5024\u3092\u6e21\u3059\u305f\u3081\u306eProperties\u3084Variables\u3068\u3044\u3063\u305f\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3 id=\"toc_4\">GitLab CI<\/h3>\n<p>GitLab CI\u3067\u306f\u7570\u306a\u308bYAML\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u5f15\u3063\u5f35\u3063\u3066\u304f\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u305d\u308c\u3092\u8a2d\u5b9a\u5185\u5bb9\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u307e\u305fVariables\u306e\u6a5f\u80fd\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u306f\u3001include\u3057\u305f\u5024\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30d9\u30fc\u30b9\u3068\u306a\u308bYAML\u304c\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"autodevops-template.yml\" ># Content of https:\/\/company.com\/autodevops-template.yml\n\nvariables:\n  POSTGRES_USER: user\n  POSTGRES_PASSWORD: testing_password\n  POSTGRES_DB: $CI_ENVIRONMENT_SLUG\n\nproduction:\n  stage: production\n  script:\n    - install_dependencies\n    - deploy\n  environment:\n    name: production\n    url: https:\/\/$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN\n  only:\n    - master<\/pre>\n<p>CI\u304c\u4f7f\u7528\u3059\u308b<code>.gitlab-ci.yml<\/code>\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\".gitlab-ci.yml\" ># Content of .gitlab-ci.yml\n\ninclude: 'https:\/\/company.com\/autodevops-template.yml'\n\nimage: alpine:latest\n\nvariables:\n  POSTGRES_USER: root\n  POSTGRES_PASSWORD: secure_password\n\nstages:\n  - build\n  - test\n  - production\n\nproduction:\n  environment:\n    url: https:\/\/domain.com<\/pre>\n<p><code>POSTGRES_USER<\/code>, <code>POSTGRES_PASSWORD<\/code>\u306f\u4e0a\u66f8\u304d\u3055\u308c\u307e\u3059\u3057\u3001<code>production<\/code>\u306e\u30bf\u30b9\u30af\u306f<code>url<\/code>\u304c\u4e0a\u66f8\u304d\u3055\u308c\u307e\u3059\u3002\u30bf\u30b9\u30af\u306e\u5185\u5bb9\u81ea\u4f53\u306f<code>autodevops-template.yml<\/code>\u306e\u5185\u5bb9\u304c\u5229\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.gitlab.com\/ee\/ci\/yaml\/#include\">Configuration of your jobs with .gitlab-ci.yml | GitLab include<\/a><\/li>\n<\/ul>\n<h3 id=\"toc_5\">AWS CloudFormation<\/h3>\n<p>CloudFormation\u3067\u306fParameters\u3084Mapping\u3001\u307e\u305f\u72ec\u81ea\u306e\u95a2\u6570\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"parameters-sample.yml\" >Parameters: \n  InstanceType: \n    Type: 'AWS::SSM::Parameter::Value<String>'\nResources: \n  Instance: \n    Type: 'AWS::EC2::Instance'\n    Properties: \n      InstanceType: !Ref InstanceType<\/pre>\n<p>EC2\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30bf\u30a4\u30d7\u306fPrameter\u306e<code>InstanceType<\/code>\u3067\u8a2d\u5b9a\u3055\u308c\u305f\u5024\u304c\u5229\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"mappings-sample.yml\" >AWSTemplateFormatVersion: \"2010-09-09\"\nMappings: \n  RegionMap: \n    us-east-1: \n      \"32\": \"ami-6411e20d\"\n      \"64\": \"ami-7a11e213\"\n    us-west-1: \n      \"32\": \"ami-c9c7978c\"\n      \"64\": \"ami-cfc7978a\"\n    eu-west-1: \n      \"32\": \"ami-37c2f643\"\n      \"64\": \"ami-31c2f645\"\n    ap-southeast-1: \n      \"32\": \"ami-66f28c34\"\n      \"64\": \"ami-60f28c32\"\n    ap-northeast-1: \n      \"32\": \"ami-9c03a89d\"\n      \"64\": \"ami-a003a8a1\"\nResources: \n  myEC2Instance: \n    Type: \"AWS::EC2::Instance\"\n    Properties: \n      ImageId: !FindInMap [RegionMap, !Ref \"AWS::Region\", 32]\n      InstanceType: m1.small<\/pre>\n<p>Mapping\u3067\u306f\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u5024\u304c\u5229\u7528\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070<code>ap-northeast-1<\/code>\u3067\u5b9f\u884c\u3055\u308c\u305f\u5834\u5408\u306b\u306f<code>ap-northeast-1.32<\/code>\u306b\u5bfe\u5fdc\u3059\u308b\u5024\u3067\u3042\u308b<code>ami-9c03a89d<\/code>\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/parameters-section-structure.html\">Parameters - AWS CloudFormation<\/a><\/li>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/ja_jp\/AWSCloudFormation\/latest\/UserGuide\/mappings-section-structure.html\">Mappings - AWS CloudFormation<\/a><\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u306e\u65b9\u6cd5\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306aPros\/Cons\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><strong>Pros<\/strong>: \u30c4\u30fc\u30eb\u306b\u6700\u9069\u5316\u3055\u308c\u305f\u65b9\u6cd5\u3067\u8a2d\u5b9a\u306e\u5171\u901a\u5316\u304c\u884c\u3048\u3001\u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u307e\u305f\u3050\u5171\u901a\u5316\u3082\u53ef\u80fd\u306b\u306a\u308b<br \/>\n<strong>Cons<\/strong>: \u30c4\u30fc\u30eb\u304c\u5909\u308f\u308b\u3068\u518d\u5229\u7528\u3067\u304d\u306a\u304f\u306a\u308b\u3002YAML\u306e\u62e1\u5f35\u90e8\u5206\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p>\u7279\u306bCloudFormation\u306f\u3059\u3054\u3044\u3067\u3059\u306d\u3002\u3067\u3082\u306a\u3093\u304b\u6577\u5c45\u306e\u9ad8\u3055\u3092\u611f\u3058\u3066\u3057\u307e\u3046\u3057\u3001\u66f8\u304f\u306e\u304c\u5927\u5909\u3060\u306a\u3041\u3068\u3044\u3046\u6c17\u6301\u3061\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2 id=\"toc_6\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3092\u4f7f\u3046<\/h2>\n<p>YAML\u5185\u90e8\u306e\u9805\u76ee\u3084\u3001\u4e0e\u3048\u308b\u3079\u304d\u30d1\u30e9\u30e1\u30fc\u30bf\u3082\u52d5\u7684\u306b\u751f\u6210\u3057\u305f\u3044\u306e\u3067\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3084\u3063\u3066\u3057\u307e\u304a\u3046\u3068\u3044\u3046\u30b1\u30fc\u30b9\u3067\u3059\u3002<\/p>\n<h3 id=\"toc_7\">Python\u3067\u3084\u308b<\/h3>\n<p>CloudFormation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8a18\u8ff0\u3057\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u306b\u52a0\u3048\u3066<\/p>\n<ul>\n<li>\u521d\u671f\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u751f\u6210\u304c\u5fc5\u8981<\/li>\n<li>\u30e6\u30fc\u30b6\u30fc\u304c\u52d5\u7684\u306a\u305f\u3081CloudFormation\u306eParameters\u3082\u52d5\u7684\u306b\u8a18\u8ff0\u304c\u5fc5\u8981<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u7406\u7531\u3067\u3001\u5b9f\u884c\u6642\u306b\u4f7f\u7528\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u3082\u751f\u6210\u3057\u3066\u307f\u305f\u4f8b\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f<a href=\"http:\/\/jinja.pocoo.org\/\">Jinja2<\/a>\u3068\u3044\u3046\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<br \/>\n\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u30b3\u30fc\u30c9\u306f\u3053\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u306f\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u51e6\u7406\u306e\u524d\u306b\u6e96\u5099\u3055\u308c\u3066\u3044\u308b\u72b6\u614b\u3067\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 lang:python decode:true \" title=\"create-user-yaml.py\" >from jinja2 import Template\n\nusers = prepare_users()\n# load_jinja_yaml \u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\ntemplate = Template(load_jinja_yaml())\nprint(template.render(user_resources=users))\n<\/pre>\n<p>YAML\u306b\u306a\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u90e8\u5206\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<code>for<\/code>\u3092\u4f7f\u7528\u3057\u305f\u7e70\u308a\u8fd4\u3057\u306e\u8a18\u8ff0\u304c\u3067\u304d\u308b\u306e\u304c\u5b09\u3057\u3044\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"users.jinja.yaml\" >AWSTemplateFormatVersion: \"2010-09-09\"\nDescription: Create IAM Users\n\nParameters:\n{% for res in user_resources %}\n  {{ res.param_name }}:\n    Description: password for {{ res.user_name }}\n    Type: String\n    NoEcho: true\n{% endfor %}\n\nResources:\n{% for res in user_resources %}\n  {{res.resource_name}}:\n    Type: AWS::IAM::User\n    Properties:\n      UserName: \"{{ res.user_name }}\"\n      LoginProfile:\n        Password: !Ref {{res.param_name}}\n        PasswordResetRequired: true\n      Groups:\n        - Administrators\n      ManagedPolicyArns:\n        - \"arn:aws:iam::aws:policy\/IAMUserChangePassword\"\n{% endfor %}<\/pre>\n<p>\u3053\u308c\u3067CloudFormation\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>Pros<\/strong>: \u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306b\u3088\u308b\u751f\u6210\u306e\u305f\u3081\u67d4\u8edf\u6027\u304c\u9ad8\u3044\u3002\u597d\u304d\u306a\u3088\u3046\u306b\u751f\u6210\u3067\u304d\u308b\u3002<br \/>\n<strong>Cons<\/strong>:  \u4f55\u5ea6\u3082\u4f7f\u7528\u3059\u308b\u5834\u5408\u306b\u306f\u3001\u4f8b\u5916\u30b1\u30fc\u30b9\u306a\u3069\u3092\u8003\u616e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002\u30dc\u30ea\u30e5\u30fc\u30e0\u304c\u5927\u304d\u304f\u306a\u308b\u3068\u3081\u3093\u3069\u304f\u3055\u304f\u306a\u308b<\/p>\n<h2 id=\"toc_8\">\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30b3\u30de\u30f3\u30c9)\u3067\u306a\u3093\u3068\u304b<\/h2>\n<p>\u3082\u3063\u3068\u697d\u306b\u3067\u304d\u306a\u3044\u3082\u3093\u3067\u3057\u3087\u3046\u304b\u3002\u96d1\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><code>template.yaml<\/code>\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 wrap:true lang:yaml\" title=\"template.yaml\" >applications:\n  - name: ${PREFIX}super-api\n    buildpacks:\n      - nodejs_buildpack\n    memory: 128MB\n    instances: 2\n    env:\n      LOG_LEVEL: ${LOG_LEVEL}\n    routes:\n      - route: ${PREFIX}super-api.example.com\n<\/pre>\n<p>\u305d\u3057\u3066\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7528\u610f\u3057\u307e\u3059\u3002<code>create_yaml.sh<\/code>\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"theme:monokai toolbar:1 lang:sh decode:true \" title=\"create_yaml.sh\" >#!\/bin\/bash\n\nPREFIX=dev-\nLOG_LEVEL=debug\nMANIFEST_FILE=manifest.yaml\n\neval \"echo \\\"$(cat template.yaml)\\\"\" | tee $MANIFEST_FILE<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\uff01<\/p>\n<pre class=\"theme:monokai toolbar:1 lang:sh decode:true \" title=\"output\" >$ bash .\/create_yaml.sh\napplications:\n  - name: dev-super-api\n    buildpacks:\n      - nodejs_buildpack\n    memory: 128MB\n    instances: 2\n    env:\n      LOG_LEVEL: debug\n    routes:\n      - route: dev-super-api.example.com\n$ ls\ncreate_yaml.sh*  manifest.yaml  template.yaml<\/pre>\n<p><code>template.yaml<\/code>\u306e\u4e2d\u306b\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u5909\u6570\u3092eval\u3092\u4f7f\u3063\u3066\u8a55\u4fa1\u3059\u308b\u3053\u3068\u3067\u5024\u3092\u57cb\u3081\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u306a\u3093\u304b\u624b\u3063\u53d6\u308a\u65e9\u3055\u306f\u4e00\u756a\u306e\u3088\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<p><strong>Pros<\/strong>: \u30b7\u30f3\u30d7\u30eb\u306b\u3067\u304d\u308b<br \/>\n<strong>Cons<\/strong>: \u5171\u901a\u5316\u3084\u5024\u306e\u4e0a\u66f8\u304d\u306f\u3084\u3084\u3053\u3057\u304f\u306a\u308a\u305d\u3046<\/p>\n<h2 id=\"toc_9\">\u304a\u308f\u308a\u306b<\/h2>\n<p>\u30c4\u30fc\u30eb\u306b\u3088\u308b\u62e1\u5f35\u6a5f\u80fd\u304c\u4e00\u756a\u4f7f\u3044\u3084\u3059\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001Include\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u306a\u3044\u30c4\u30fc\u30eb\u3060\u3068\u306a\u304b\u306a\u304b\u3064\u3089\u3044\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002\u4ee3\u66ff\u306e\u65b9\u6cd5\u3092\u3044\u308d\u3044\u308d\u3068\u6a21\u7d22\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u4fdd\u5b88\u6027\u3092\u4e0b\u3052\u305a\u306b\u7c21\u5358\u306b\u8a18\u8ff0\u3067\u304d\u308b\u9280\u306e\u5f3e\u4e38\u7684\u306a\u3082\u306e\u306f\u306a\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u30b5\u30dc\u308d\u3046\u3068\u305b\u305a\u5730\u9053\u306b\u66f8\u304f\u3001\u3068\u3044\u3046\u306e\u304c\u4e00\u756a\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u6cb3\u91ce\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306fTECHSCORE Advent Calendar 2018 \u306e3\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<p>\u6700\u8fd1\u3044\u308d\u3044\u308d\u306a\u30c4\u30fc\u30eb\u3001\u4f8b\u3048\u3070CI\u3068\u304b\u3001PaaS\u3068\u304b\u3092\u89e6\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u306fYAML\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2018\/12\/03\/generation-of-yaml-file\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[308,18],"tags":[141,50],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/19303"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=19303"}],"version-history":[{"count":21,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/19303\/revisions"}],"predecessor-version":[{"id":19361,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/19303\/revisions\/19361"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=19303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=19303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=19303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}