Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resolve #1283] Deprecating iam_role, role_arn, and template_path; Introducing sceptre_role, cloudformation_service_role #1295

Merged
merged 17 commits into from
Jan 24, 2023

Conversation

jfalkenstein
Copy link
Contributor

@jfalkenstein jfalkenstein commented Jan 22, 2023

This PR brings about three Stack Config deprecations (two of which have been renamed).

  • iam_role has been deprecated and aliased to a new Stack Config key of sceptre_role. This change has also been made on the ConnectionManager.
  • role_arn has been deprecated and aliased to a new Stack Config key of cloudformation_service_role.
  • template_path has been deprecated officially (it has been discouraged in docs since 2.7 but this makes it official). Functionality on this hasn't really changed apart from the warnings (see below).

With these deprecations, Sceptre will now emit DeprecationWarnings whenever these fields are set or accessed. All locations within Sceptre have been fixed, but external and custom hooks and resolvers will also need to be updated if they're referencing these deprecated fields.

PR Checklist

  • Wrote a good commit message & description [see guide below].
  • Commit message starts with [Resolve #issue-number].
  • Added/Updated unit tests.
  • Added/Updated integration tests (if applicable).
  • All unit tests (make test) are passing.
  • Used the same coding conventions as the rest of the project.
  • The new code passes pre-commit validations (pre-commit run --all-files).
  • The PR relates to only one subject with a clear title.
    and description in grammatically correct, complete sentences.

Approver/Reviewer Checklist

  • Before merge squash related commits.

Other Information

Guide to writing a good commit

@jfalkenstein jfalkenstein self-assigned this Jan 22, 2023
@jfalkenstein jfalkenstein marked this pull request as ready for review January 22, 2023 19:12
Comment on lines +154 to +164
iam_role = create_deprecated_alias_property(
"iam_role", "sceptre_role", "4.0.0", "5.0.0"
)
role_arn = create_deprecated_alias_property(
"role_arn", "cloudformation_service_role", "4.0.0", "5.0.0"
)
sceptre_role_session_duration = None
iam_role_session_duration = create_deprecated_alias_property(
"iam_role_session_duration", "sceptre_role_session_duration", "4.0.0", "5.0.0"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "deprecated alias properties" emit deprecation warnings and ultimately resolve to the correct values, both for getting and setting. You can find this function here: https://github.com/Sceptre/sceptre/pull/1295/files#diff-590afffaaf0b4f3a07656251e95e9b01e40c65fe8b5f8a9bf6cd84f4d3a1e5c4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty slick.

Copy link
Contributor

@zaro0508 zaro0508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, much more clear. thanks!

@@ -24,8 +24,11 @@ particular Stack. The available keys are listed below.
- `parameters`_ *(optional)*
- `protected`_ *(optional)*
- `role_arn`_ *(optional)*
- `cloudformation_service_role`_ *(optional)*
- `iam_role`_ *(optional)*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to mark these as deprecated here as well? something like [Deprecated] iam_role_ *(optional)*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that... that's easy enough to do.

Copy link
Contributor

@dboitnot dboitnot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't spot any issues.


For more information on this configuration, its implications, and its uses, see
:ref:`Sceptre and IAM: iam_role_session_duration <iam_role_permissions>`.
If you set the value of ``sceptre_role_session_duration`` to a number that *GREATER* than 3600, you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a vestigial "that" here. I think this is supposed to read: "to a number GREATER than"

Comment on lines +154 to +164
iam_role = create_deprecated_alias_property(
"iam_role", "sceptre_role", "4.0.0", "5.0.0"
)
role_arn = create_deprecated_alias_property(
"role_arn", "cloudformation_service_role", "4.0.0", "5.0.0"
)
sceptre_role_session_duration = None
iam_role_session_duration = create_deprecated_alias_property(
"iam_role_session_duration", "sceptre_role_session_duration", "4.0.0", "5.0.0"
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty slick.

@jfalkenstein jfalkenstein merged commit 6910400 into Sceptre:master Jan 24, 2023
@jfalkenstein jfalkenstein deleted the 1283-attribute-deprecations branch January 24, 2023 15:39
jfalkenstein added a commit that referenced this pull request Feb 11, 2023
## 4.0.0 (2023.02.08)

### Added
 - [Resolve #1283] Introducing `sceptre_role`, `cloudformation_service_role` (#1295)
   - These are just iam_role and role_arn renamed to be a lot clearer. See "Deprecations" below.


### Changed
 - [Resolve #1299] Making the ConnectionManager a more "friendly" interface for hooks, resolvers,
   and template handlers (#1287, #1300)
   - This creates adds the public `get_session()` and
     `create_session_environment_variables()` methods to make AWS interactions
     easier and more consistent with individual stack configurations for
     iam_role, profile, and region configurations.
   - The `call()` method now properly distinguishes between default stack
     configurations for profile, region, and `sceptre_role` and setting those to
     `None` to nullify them.
 - Preventing Duplicate Deprecation Warnings from being emitted (#1297)

#### _Potentially_ Breaking Changes
 - The !cmd hook now invokes the passed command using the AWS environment
   variables that correspond with the stack's IAM configurations (i.e. iam_role,
   profile, region). This means that the hook will operate the same as every
   other part of Sceptre and regard how the stack is configured. This should make
   it easier to invoke other tools like AWS CLI with your hooks. However, if
   your project is setting environment variables with the intent to change how
   the command authenticates with AWS (such as a different token, profile, or
   region), these environment variables will be overridden. To maintain the same
   functionality, you should prefix your command with
   `export AWS_SESSION_TOKEN={{environment_variable.AWS_SESSION_TOKEN}} &&` (or
   whatever other environment variable(s) you need to explicitly set).

### Deprecations
 - [Resolve #1283] Deprecating `iam_role`, `role_arn`, and `template_path` (#1295)
   - `iam_role` and `role_arn` have been aliased to `sceptre_role` and
      `cloudformation_service_role`. Using these fields will result in a
      DeprecationWarning.
   - `template_path` has actually been slated for removal since v2.7. `template`
      should be used instead. Using `template_path` will result in a
      DeprecationWarning.
   - All three deprecated StackConfig fields will be removed in v5.0.0.

## 3.3.0 (2023.02.06)

### Added
 - [Resolve #1261] Add coloured differ (#1260)
   - Implements coloured diffs for the diff (difflib) command. Responds to --no-color.
 - [Resolves #1271] Extend stack colourer to include "IMPORT" states (#1272)
 - [Resolves #1179] cloudformation disable-rollback option (#1282)
   - Allow user to disable a cloudformation rollback on a sceptre deployment.

### Changed
 - [Resolve #1098] Deploy docker container to sceptreorg repo (#1265)
   - Deploy sceptre docker images to dockerhub sceptreorg repo instead of cloudreach repo
 - Updating Setuptools and wheel versions to avert security issues
 - [Resolve #1293] Improve the Stack Config Jinja Syntax Error Message to include the Stack Name (#1294)
 - [Resolves #1267] Improve the Stack Config Jinja Error Message to include the Stack Name (#1269)

### Fixed
 - [Resolve #1273] Events start from response time (#1275)
   - Resolves #1273 by starting event filtering from the timestamp returned in
     the AWS response headers rather than relying on the workstation clock.
 - [Resolve #1253] Failed downloads raise error (#1277)
   - Throwing an informative error when the template fails to download instead
     of passing the error message to CloudFormation.
 - [Resolves #1179] Changed disable-rollback default to None (#1288)
   - We want the default value to be None to represent "Do whatever's configured
     in the StackConfig" and True/False will override the StackConfig.

### Nonfunctional
 - Add tweet-release to CircleCI config (#1259)
 - [Resolves #1276] Adopt Black Auto-formatter (#1278)
   - Reformatting all Python files using the Black code formatter. This also
     delivers a new function for generating `__repr__` methods which was needed
     to deal with a line-too-long issue in Template. Per discussion in #1276 this
     PR also disables E203 in flake8.
 - Update sceptre-circleci docker image (#1284)
   - Update to build and test with a docker image that's based on the official
     circleci python docker image.
 - [Resolve #1264] Updating the CDK docs to point to the new sceptre-cdk-handler
   (#1285)
   - This updates our docs to no longer reference the old CDK approach (which
     didn't work with CDK assets). In its place, it references the new
     sceptre-cdk-handler package that covers that functionality.
zaro0508 added a commit to zaro0508/sceptre that referenced this pull request Nov 15, 2023
Use of the `template_path` template config parameter has been
discouraged since Sceptre version 2.7 and has been officially
deprecated for about 2 years now (PR Sceptre#1295).  This removes
the template_path config parameter for good.
zaro0508 added a commit to zaro0508/sceptre that referenced this pull request Nov 15, 2023
Use of the `template_path` template config parameter has been
discouraged since Sceptre version 2.7 and has been officially
deprecated for about 2 years now (PR Sceptre#1295).  This removes
the template_path config parameter for good.

This should be pushed out in a version 5.x release.
zaro0508 added a commit that referenced this pull request Dec 12, 2023
Use of the `template_path` template config parameter has been
discouraged since Sceptre version 2.7 and has been officially
deprecated for about 2 years now (PR #1295).  This removes the
template_path config parameter for good.

This should be pushed out in a version 5.x release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants