1.. _community.aws.lambda_alias_module: 2 3 4************************** 5community.aws.lambda_alias 6************************** 7 8**Creates, updates or deletes AWS Lambda function aliases** 9 10 11Version added: 1.0.0 12 13.. contents:: 14 :local: 15 :depth: 1 16 17 18Synopsis 19-------- 20- This module allows the management of AWS Lambda functions aliases via the Ansible framework. It is idempotent and supports "Check" mode. Use module :ref:`community.aws.lambda <community.aws.lambda_module>` to manage the lambda function itself and :ref:`community.aws.lambda_event <community.aws.lambda_event_module>` to manage event source mappings. 21 22 23 24Requirements 25------------ 26The below requirements are needed on the host that executes this module. 27 28- boto 29- boto3 30- python >= 2.6 31 32 33Parameters 34---------- 35 36.. raw:: html 37 38 <table border=0 cellpadding=0 class="documentation-table"> 39 <tr> 40 <th colspan="1">Parameter</th> 41 <th>Choices/<font color="blue">Defaults</font></th> 42 <th width="100%">Comments</th> 43 </tr> 44 <tr> 45 <td colspan="1"> 46 <div class="ansibleOptionAnchor" id="parameter-"></div> 47 <b>aws_access_key</b> 48 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 49 <div style="font-size: small"> 50 <span style="color: purple">string</span> 51 </div> 52 </td> 53 <td> 54 </td> 55 <td> 56 <div>AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used.</div> 57 <div>If <em>profile</em> is set this parameter is ignored.</div> 58 <div>Passing the <em>aws_access_key</em> and <em>profile</em> options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.</div> 59 <div style="font-size: small; color: darkgreen"><br/>aliases: ec2_access_key, access_key</div> 60 </td> 61 </tr> 62 <tr> 63 <td colspan="1"> 64 <div class="ansibleOptionAnchor" id="parameter-"></div> 65 <b>aws_ca_bundle</b> 66 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 67 <div style="font-size: small"> 68 <span style="color: purple">path</span> 69 </div> 70 </td> 71 <td> 72 </td> 73 <td> 74 <div>The location of a CA Bundle to use when validating SSL certificates.</div> 75 <div>Only used for boto3 based modules.</div> 76 <div>Note: The CA Bundle is read 'module' side and may need to be explicitly copied from the controller if not run locally.</div> 77 </td> 78 </tr> 79 <tr> 80 <td colspan="1"> 81 <div class="ansibleOptionAnchor" id="parameter-"></div> 82 <b>aws_config</b> 83 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 84 <div style="font-size: small"> 85 <span style="color: purple">dictionary</span> 86 </div> 87 </td> 88 <td> 89 </td> 90 <td> 91 <div>A dictionary to modify the botocore configuration.</div> 92 <div>Parameters can be found at <a href='https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config'>https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config</a>.</div> 93 <div>Only the 'user_agent' key is used for boto modules. See <a href='http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto'>http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto</a> for more boto configuration.</div> 94 </td> 95 </tr> 96 <tr> 97 <td colspan="1"> 98 <div class="ansibleOptionAnchor" id="parameter-"></div> 99 <b>aws_secret_key</b> 100 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 101 <div style="font-size: small"> 102 <span style="color: purple">string</span> 103 </div> 104 </td> 105 <td> 106 </td> 107 <td> 108 <div>AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used.</div> 109 <div>If <em>profile</em> is set this parameter is ignored.</div> 110 <div>Passing the <em>aws_secret_key</em> and <em>profile</em> options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.</div> 111 <div style="font-size: small; color: darkgreen"><br/>aliases: ec2_secret_key, secret_key</div> 112 </td> 113 </tr> 114 <tr> 115 <td colspan="1"> 116 <div class="ansibleOptionAnchor" id="parameter-"></div> 117 <b>debug_botocore_endpoint_logs</b> 118 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 119 <div style="font-size: small"> 120 <span style="color: purple">boolean</span> 121 </div> 122 </td> 123 <td> 124 <ul style="margin: 0; padding: 0"><b>Choices:</b> 125 <li><div style="color: blue"><b>no</b> ←</div></li> 126 <li>yes</li> 127 </ul> 128 </td> 129 <td> 130 <div>Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used.</div> 131 </td> 132 </tr> 133 <tr> 134 <td colspan="1"> 135 <div class="ansibleOptionAnchor" id="parameter-"></div> 136 <b>description</b> 137 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 138 <div style="font-size: small"> 139 <span style="color: purple">string</span> 140 </div> 141 </td> 142 <td> 143 </td> 144 <td> 145 <div>A short, user-defined function alias description.</div> 146 </td> 147 </tr> 148 <tr> 149 <td colspan="1"> 150 <div class="ansibleOptionAnchor" id="parameter-"></div> 151 <b>ec2_url</b> 152 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 153 <div style="font-size: small"> 154 <span style="color: purple">string</span> 155 </div> 156 </td> 157 <td> 158 </td> 159 <td> 160 <div>Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used.</div> 161 <div style="font-size: small; color: darkgreen"><br/>aliases: aws_endpoint_url, endpoint_url</div> 162 </td> 163 </tr> 164 <tr> 165 <td colspan="1"> 166 <div class="ansibleOptionAnchor" id="parameter-"></div> 167 <b>function_name</b> 168 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 169 <div style="font-size: small"> 170 <span style="color: purple">string</span> 171 / <span style="color: red">required</span> 172 </div> 173 </td> 174 <td> 175 </td> 176 <td> 177 <div>The name of the function alias.</div> 178 </td> 179 </tr> 180 <tr> 181 <td colspan="1"> 182 <div class="ansibleOptionAnchor" id="parameter-"></div> 183 <b>function_version</b> 184 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 185 <div style="font-size: small"> 186 <span style="color: purple">integer</span> 187 </div> 188 </td> 189 <td> 190 </td> 191 <td> 192 <div>Version associated with the Lambda function alias. A value of 0 (or omitted parameter) sets the alias to the $LATEST version.</div> 193 <div style="font-size: small; color: darkgreen"><br/>aliases: version</div> 194 </td> 195 </tr> 196 <tr> 197 <td colspan="1"> 198 <div class="ansibleOptionAnchor" id="parameter-"></div> 199 <b>name</b> 200 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 201 <div style="font-size: small"> 202 <span style="color: purple">string</span> 203 / <span style="color: red">required</span> 204 </div> 205 </td> 206 <td> 207 </td> 208 <td> 209 <div>Name of the function alias.</div> 210 <div style="font-size: small; color: darkgreen"><br/>aliases: alias_name</div> 211 </td> 212 </tr> 213 <tr> 214 <td colspan="1"> 215 <div class="ansibleOptionAnchor" id="parameter-"></div> 216 <b>profile</b> 217 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 218 <div style="font-size: small"> 219 <span style="color: purple">string</span> 220 </div> 221 </td> 222 <td> 223 </td> 224 <td> 225 <div>Uses a boto profile. Only works with boto >= 2.24.0.</div> 226 <div>Using <em>profile</em> will override <em>aws_access_key</em>, <em>aws_secret_key</em> and <em>security_token</em> and support for passing them at the same time as <em>profile</em> has been deprecated.</div> 227 <div><em>aws_access_key</em>, <em>aws_secret_key</em> and <em>security_token</em> will be made mutually exclusive with <em>profile</em> after 2022-06-01.</div> 228 <div style="font-size: small; color: darkgreen"><br/>aliases: aws_profile</div> 229 </td> 230 </tr> 231 <tr> 232 <td colspan="1"> 233 <div class="ansibleOptionAnchor" id="parameter-"></div> 234 <b>region</b> 235 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 236 <div style="font-size: small"> 237 <span style="color: purple">string</span> 238 </div> 239 </td> 240 <td> 241 </td> 242 <td> 243 <div>The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See <a href='http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region'>http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region</a></div> 244 <div style="font-size: small; color: darkgreen"><br/>aliases: aws_region, ec2_region</div> 245 </td> 246 </tr> 247 <tr> 248 <td colspan="1"> 249 <div class="ansibleOptionAnchor" id="parameter-"></div> 250 <b>security_token</b> 251 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 252 <div style="font-size: small"> 253 <span style="color: purple">string</span> 254 </div> 255 </td> 256 <td> 257 </td> 258 <td> 259 <div>AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.</div> 260 <div>If <em>profile</em> is set this parameter is ignored.</div> 261 <div>Passing the <em>security_token</em> and <em>profile</em> options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.</div> 262 <div style="font-size: small; color: darkgreen"><br/>aliases: aws_security_token, access_token</div> 263 </td> 264 </tr> 265 <tr> 266 <td colspan="1"> 267 <div class="ansibleOptionAnchor" id="parameter-"></div> 268 <b>state</b> 269 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 270 <div style="font-size: small"> 271 <span style="color: purple">string</span> 272 </div> 273 </td> 274 <td> 275 <ul style="margin: 0; padding: 0"><b>Choices:</b> 276 <li><div style="color: blue"><b>present</b> ←</div></li> 277 <li>absent</li> 278 </ul> 279 </td> 280 <td> 281 <div>Describes the desired state.</div> 282 </td> 283 </tr> 284 <tr> 285 <td colspan="1"> 286 <div class="ansibleOptionAnchor" id="parameter-"></div> 287 <b>validate_certs</b> 288 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> 289 <div style="font-size: small"> 290 <span style="color: purple">boolean</span> 291 </div> 292 </td> 293 <td> 294 <ul style="margin: 0; padding: 0"><b>Choices:</b> 295 <li>no</li> 296 <li><div style="color: blue"><b>yes</b> ←</div></li> 297 </ul> 298 </td> 299 <td> 300 <div>When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.</div> 301 </td> 302 </tr> 303 </table> 304 <br/> 305 306 307Notes 308----- 309 310.. note:: 311 - If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ``AWS_URL`` or ``EC2_URL``, ``AWS_PROFILE`` or ``AWS_DEFAULT_PROFILE``, ``AWS_ACCESS_KEY_ID`` or ``AWS_ACCESS_KEY`` or ``EC2_ACCESS_KEY``, ``AWS_SECRET_ACCESS_KEY`` or ``AWS_SECRET_KEY`` or ``EC2_SECRET_KEY``, ``AWS_SECURITY_TOKEN`` or ``EC2_SECURITY_TOKEN``, ``AWS_REGION`` or ``EC2_REGION``, ``AWS_CA_BUNDLE`` 312 - Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See https://boto.readthedocs.io/en/latest/boto_config_tut.html 313 - ``AWS_REGION`` or ``EC2_REGION`` can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file 314 315 316 317Examples 318-------- 319 320.. code-block:: yaml 321 322 --- 323 # Simple example to create a lambda function and publish a version 324 - hosts: localhost 325 gather_facts: no 326 vars: 327 state: present 328 project_folder: /path/to/deployment/package 329 deployment_package: lambda.zip 330 account: 123456789012 331 production_version: 5 332 tasks: 333 - name: AWS Lambda Function 334 lambda: 335 state: "{{ state | default('present') }}" 336 name: myLambdaFunction 337 publish: True 338 description: lambda function description 339 code_s3_bucket: package-bucket 340 code_s3_key: "lambda/{{ deployment_package }}" 341 local_path: "{{ project_folder }}/{{ deployment_package }}" 342 runtime: python2.7 343 timeout: 5 344 handler: lambda.handler 345 memory_size: 128 346 role: "arn:aws:iam::{{ account }}:role/API2LambdaExecRole" 347 348 - name: Get information 349 lambda_info: 350 name: myLambdaFunction 351 register: lambda_info 352 - name: show results 353 ansible.builtin.debug: 354 msg: "{{ lambda_info['lambda_facts'] }}" 355 356 # The following will set the Dev alias to the latest version ($LATEST) since version is omitted (or = 0) 357 - name: "alias 'Dev' for function {{ lambda_info.lambda_facts.FunctionName }} " 358 community.aws.lambda_alias: 359 state: "{{ state | default('present') }}" 360 function_name: "{{ lambda_info.lambda_facts.FunctionName }}" 361 name: Dev 362 description: Development is $LATEST version 363 364 # The QA alias will only be created when a new version is published (i.e. not = '$LATEST') 365 - name: "alias 'QA' for function {{ lambda_info.lambda_facts.FunctionName }} " 366 community.aws.lambda_alias: 367 state: "{{ state | default('present') }}" 368 function_name: "{{ lambda_info.lambda_facts.FunctionName }}" 369 name: QA 370 version: "{{ lambda_info.lambda_facts.Version }}" 371 description: "QA is version {{ lambda_info.lambda_facts.Version }}" 372 when: lambda_info.lambda_facts.Version != "$LATEST" 373 374 # The Prod alias will have a fixed version based on a variable 375 - name: "alias 'Prod' for function {{ lambda_info.lambda_facts.FunctionName }} " 376 community.aws.lambda_alias: 377 state: "{{ state | default('present') }}" 378 function_name: "{{ lambda_info.lambda_facts.FunctionName }}" 379 name: Prod 380 version: "{{ production_version }}" 381 description: "Production is version {{ production_version }}" 382 383 384 385Return Values 386------------- 387Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: 388 389.. raw:: html 390 391 <table border=0 cellpadding=0 class="documentation-table"> 392 <tr> 393 <th colspan="1">Key</th> 394 <th>Returned</th> 395 <th width="100%">Description</th> 396 </tr> 397 <tr> 398 <td colspan="1"> 399 <div class="ansibleOptionAnchor" id="return-"></div> 400 <b>alias_arn</b> 401 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> 402 <div style="font-size: small"> 403 <span style="color: purple">string</span> 404 </div> 405 </td> 406 <td>success</td> 407 <td> 408 <div>Full ARN of the function, including the alias</div> 409 <br/> 410 <div style="font-size: smaller"><b>Sample:</b></div> 411 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">arn:aws:lambda:us-west-2:123456789012:function:myFunction:dev</div> 412 </td> 413 </tr> 414 <tr> 415 <td colspan="1"> 416 <div class="ansibleOptionAnchor" id="return-"></div> 417 <b>description</b> 418 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> 419 <div style="font-size: small"> 420 <span style="color: purple">string</span> 421 </div> 422 </td> 423 <td>success</td> 424 <td> 425 <div>A short description of the alias</div> 426 <br/> 427 <div style="font-size: smaller"><b>Sample:</b></div> 428 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The development stage for my hot new app</div> 429 </td> 430 </tr> 431 <tr> 432 <td colspan="1"> 433 <div class="ansibleOptionAnchor" id="return-"></div> 434 <b>function_version</b> 435 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> 436 <div style="font-size: small"> 437 <span style="color: purple">string</span> 438 </div> 439 </td> 440 <td>success</td> 441 <td> 442 <div>The qualifier that the alias refers to</div> 443 <br/> 444 <div style="font-size: smaller"><b>Sample:</b></div> 445 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">$LATEST</div> 446 </td> 447 </tr> 448 <tr> 449 <td colspan="1"> 450 <div class="ansibleOptionAnchor" id="return-"></div> 451 <b>name</b> 452 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> 453 <div style="font-size: small"> 454 <span style="color: purple">string</span> 455 </div> 456 </td> 457 <td>success</td> 458 <td> 459 <div>The name of the alias assigned</div> 460 <br/> 461 <div style="font-size: smaller"><b>Sample:</b></div> 462 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">dev</div> 463 </td> 464 </tr> 465 <tr> 466 <td colspan="1"> 467 <div class="ansibleOptionAnchor" id="return-"></div> 468 <b>revision_id</b> 469 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> 470 <div style="font-size: small"> 471 <span style="color: purple">string</span> 472 </div> 473 </td> 474 <td>success</td> 475 <td> 476 <div>A unique identifier that changes when you update the alias.</div> 477 <br/> 478 <div style="font-size: smaller"><b>Sample:</b></div> 479 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">12345678-1234-1234-1234-123456789abc</div> 480 </td> 481 </tr> 482 </table> 483 <br/><br/> 484 485 486Status 487------ 488 489 490Authors 491~~~~~~~ 492 493- Pierre Jodouin (@pjodouin), Ryan Scott Brown (@ryansb) 494