Debian Codegraph @

ansible_collections/amazon/aws/CONTRIBUTING.md

raw
1 # Contributing
2
3 ## AWS Collections
4
5 There are two related collections containing AWS content (modules and plugins).
6
7 ### amazon.aws
8 This collection contains the `module_utils` (shared libraries) used by both collections.
9 Content in this collection is included downstream in Red Hat Ansible Automation Platform.
10
11 Code standards, test coverage, and other supportability criteria may be higher in this collection.
12
13 The `amazon.aws` collection is an [Ansible-maintained collection](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html).
14
15 ### community.aws
16 This collection contains modules and plugins contributed and maintained by the Ansible AWS
17 community. The `community.aws` collection is tested and generally assured to work in
18 conjunction with `amazon.aws`.
19
20 New modules and plugins developed by the community should be proposed to `community.aws`.
21 Content in this collection that is stable and meets other acceptance criteria has the potential
22 to be promoted and migrated into `amazon.aws`.
23
24 ## Submitting Issues
25 All software has bugs, and the `amazon.aws` collection is no exception. When you find a bug,
26 you can help tremendously by [telling us about it](https://github.com/ansible-collections/amazon.aws/issues/new/choose).
27
28 If you should discover that the bug you're trying to file already exists in an issue,
29 you can help by verifying the behavior of the reported bug with a comment in that
30 issue, or by reporting any additional information
31
32 ## Writing New Code
33
34 New modules should be submitted to the [community.aws](https://github.com/ansible-collections/community.aws) collection.
35
36 For new features and bug fixes on existing modules,
37 clone this repository and try to run unit tests and integration tests by following
38 [these instructions](https://docs.ansible.com/ansible/latest/community/create_pr_quick_start.html).
39 When you get to this part:
40
41 ```
42 ansible-test integration name_of_test_subdirectory --docker -v
43 ```
44
45 Run this from the `tests` directory of this repository.
46 Substitute `name_of_test_subdirectory` for the name of the relevant directory within `tests/integration/targets`.
47 You'll get this error:
48
49 ```
50 WARNING: Excluding tests marked "cloud/aws" which require config
51 (see "/home/dev/ansible/ansible/test/lib/ansible_test/config/cloud-config-aws.ini.template"): ec2_group
52 ```
53 This is because the unit tests don't automatically detect the AWS credentials on your machine
54 unlike plain `boto3` and the `aws` cli.
55 (Typically because they're run inside Docker, which can't access `~/.aws/credentials`.
56 But even when running tests outside docker, the tests ignore `~/.aws/credentials`.)
57 You need to explicitly create credentials and load them in to an Ansible-specific file.
58 To do this, copy the file mentioned in that error message,
59 into the clone of this repo, under `tests/integration/cloud-config-aws.ini`.
60 Modify the `@` variables, pasting in an IAM secret credential.
61 If you don't need the `secret_token` (most IAM users don't), comment that line out.
62
63 You can use an AWS account that already has unrelated resources in it.
64 The tests should not touch pre-existing resources, and should tidy up after themselves.
65 (Of course for security reasons you may want to run in a dedicated AWS account.)
66
67 If you're only writing a pull request for one AWS service
68 you are able to create credentials only with permissions required for that test.
69 For example, to test the Lambda modules, you only need Lambda permissions,
70 and permissions to create IAM roles.
71 You could also deploy [the policies used by the CI](https://github.com/mattclay/aws-terminator/tree/master/aws/policy).
72
73 All modules MUST have integration tests for new features.
74 Bug fixes for modules that currently have integration tests SHOULD have tests added.
75
76 Once you're able to run integration tests for the existing code,
77 now start by adding tests in `tests/integration/targets`
78 for your new feature or tests for the bug(s) you're about to fix.
79
80 Expected test criteria:
81 * Resource creation under check mode
82 * Resource creation
83 * Resource creation again (idempotency) under check mode
84 * Resource creation again (idempotency)
85 * Resource modification under check mode
86 * Resource modification
87 * Resource modification again (idempotency) under check mode
88 * Resource modification again (idempotency)
89 * Resource deletion under check mode
90 * Resource deletion
91 * Resource deletion (of a non-existent resource) under check mode
92 * Resource deletion (of a non-existent resource)
93
94 Where modules have multiple parameters we recommend running through the 4-step modification cycle for each parameter the module accepts, as well as a modification cycle where as most, if not all, parameters are modified at the same time.
95
96 After writing the tests, now write/modify the module code, typically in `plugins/modules`.
97 Don't forget to add [a changelog entry](https://docs.ansible.com/ansible/latest/community/collection_development_process.html#collection-changelog-fragments).
98 Then create a pull request.
99
100 If you're struggling with running integration tests locally, don't worry.
101 After creating a pull request the GitHub Actions will automatically test for you.
102
103 ## More information about contributing
104
105 General information about setting up your Python environment, testing modules,
106 Ansible coding styles, and more can be found in the [Ansible Community Guide](
107 https://docs.ansible.com/ansible/latest/community/index.html).
108
109 Information about AWS SDK library usage, module utils, testing, and more can be
110 found in the [AWS Guidelines](https://docs.ansible.com/ansible/devel/collections/amazon/aws/docsite/dev_guidelines.html#ansible-collections-amazon-aws-docsite-dev-guide-intro)
111 documentation.
112
113 For general information on running the integration tests see
114 [this page](https://docs.ansible.com/ansible/latest/community/collection_contributors/test_index.html) and
115 [Integration Tests page of the Module Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/testing_integration.html#non-destructive-tests).
116 Ignore the part about `source hacking/env-setup`. That's only applicable for working on `ansible-core`.
117 You should be able to use the `ansible-test` that's installed with Ansible generally.
118 Look at [the section on configuration for cloud tests](https://docs.ansible.com/ansible/devel/dev_guide/testing_integration.html#other-configuration-for-cloud-tests).
119
120 - [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html) - Details on contributing to Ansible
121 - [Contributing to Collections](https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#contributing-to-collections) - How to check out collection git repositories correctly
122 - [Contributing to Ansible-maintained collections](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html#contributing-maintained-collections)
123 - [Guidelines for Ansible Amazon AWS module development](https://docs.ansible.com/ansible/latest/collections/amazon/aws/docsite/dev_guidelines.html)
124 - [Getting Started With AWS Ansible Module Development and Community Contribution](https://www.ansible.com/blog/getting-started-with-aws-ansible-module-development)
125
126 ### Code of Conduct
127 The `amazon.aws` collection follows the Ansible project's
128 [Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
129 Please read and familiarize yourself with this document.