Saturday, 10 March 2018

AWS CloudFormation (init)

Overview
  • Installing and configuring software using CF

 AWS::CloudFormation::Init
  • It is a special key put into template metadata
    • Either on the template or individual resource level
  • Defines instructions for cfn-init python script
  • Sections
    • ConfigSets
      • Specify multiple "config" keys and allows to change order of execution (e.g. config1, config2)
      • config keys may be embedded in one another
    • Commands
      • Execute Bash/cmd.exe command 
        • Parameters: command, env, cwd (working directory), test, ignoreErrors, waitAfterCompletion (windows only: used for rebooting)
    • Files
      • Create files
        • Parameters: content, source (XOR with content), group, owner, mode
      • Supports Mustache templates (require context parameter)
    • Packages
      • Download and install packages
        • Linux: yum, rpm, apt, rubygems, python
        • Windows: msi
      • May specify version
    • Services
      • Enable/Disable services
        • Linux: syvinit
        • Windows: SCM
      • Parameters: files (restart service if touched), packages, ensureRunning, enabled
    • Sources
      • Download archive and unpack it to target directory
    • Groups
    •  Users
      • Create users
        • Parameters: uid, groups, homedir
cfn-init
  • Default order
    •  packages, groups, users, sources, files, commands, services
  • Injected via "UserData" property on EC2 instance
    • "/opt/aws/bin/cfn-init"

No comments:

Post a Comment