file

You can use the files key to create files on the EC2 instance. The content can be either inline in the template or the content can be pulled from a URL. The file method maps to the AWS::CloudFormation::Init files section.

Example

file("/tmp/myfile1.txt",
  content: "/tmp/myfile1.txt",
  mode: "120644",
)
file("/tmp/myfile2.txt",
  content: "/tmp/myfile2.txt",
  mode: "120644",
)

Generates:

AWS::CloudFormation::Init:
  configSets:
    default:
    - main
  main:
    files:
      "/tmp/myfile1.txt":
        content: "/tmp/myfile1.txt"
        mode: '120644'
      "/tmp/myfile2.txt":
        content: "/tmp/myfile2.txt"
        mode: '120644'

Tip: The content_file helper, can be use to clean up the code and move content to other files.

Back to DSL Docs

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!