【问题标题】:AWS SAM with Ansible带有 Ansible 的 AWS SAM
【发布时间】:2021-05-30 02:20:56
【问题描述】:

问:我可以使用 Ansible 来构建/部署 AWS SAM(无服务器应用程序模型)模板吗? 如果是这样,任何人都可以发布这个 Ansible Playbook(例如,带有构建/部署任务)应该是什么样子的示例吗?

注意:

我在网上搜索过,但没有找到任何人举出这样的例子。 Ansible 文档中甚至没有提到 AWS SAM。除了 GitHub issue (feature idea) 建议使用 Ansible 支持 SAM - 但那是从 2017 年开始的。

非常感谢

【问题讨论】:

  • 答案会有所不同,具体取决于您是指构建为任务、部署为任务还是构建然后部署为一个任务。答案最终也是“自动执行您手动输入的任何步骤”,因为计算机是确定性的
  • 我不在乎构建部署是否会在单独的任务中,只是想知道 ansible 是否可以基于 SAM 模板部署 AWS Cloud Formation 堆栈,以及一些证明这一点的示例会很棒.
  • 谢谢,但不是我想要的,看过这个视频,这是如何使用 Ansible 在 AWS 中创建服务,但不是使用 CF / SAM 模板,我想使用创建一个 CF 堆栈SAM 模板。

标签: amazon-web-services ansible serverless-application-model


【解决方案1】:

是的,当然可以。这是 Ansible 参考帮助和另一个帮助 article


获取Serverless Plugin, help here

..."此插件是 community.general 集合(版本 3.0.2)的一部分。

要安装它,请使用:ansible-galaxy collection install community.general..."


- name: Basic deploy of a service
  community.general.serverless:
    service_path: '{{ project_dir }}'
    state: present

- name: Deploy specific functions
  community.general.serverless:
    service_path: '{{ project_dir }}'
    functions:
      - my_func_one
      - my_func_two

- name: Deploy a project, then pull its resource list back into Ansible
  community.general.serverless:
    stage: dev
    region: us-east-1
    service_path: '{{ project_dir }}'
  register: sls

# The cloudformation stack is always named the same as the full service, so the
# cloudformation_info module can get a full list of the stack resources, as
# well as stack events and outputs
- cloudformation_info:
    region: us-east-1
    stack_name: '{{ sls.service_name }}'
    stack_resources: true

- name: Deploy a project using a locally installed serverless binary
  community.general.serverless:
    stage: dev
    region: us-east-1
    service_path: '{{ project_dir }}'
    serverless_bin_path: node_modules/.bin/serverless

【讨论】:

    猜你喜欢
    • 2018-05-19
    • 2020-11-13
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 2020-10-08
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多