• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
Flyy Tech
  • Home
  • Apple
  • Applications
    • Computers
    • Laptop
    • Microsoft
  • Security
  • Smartphone
  • Gaming
  • Entertainment
    • Literature
    • Cooking
    • Fitness
    • lifestyle
    • Music
    • Nature
    • Podcasts
    • Travel
    • Vlogs
  • Camera
  • Audio
No Result
View All Result
  • Home
  • Apple
  • Applications
    • Computers
    • Laptop
    • Microsoft
  • Security
  • Smartphone
  • Gaming
  • Entertainment
    • Literature
    • Cooking
    • Fitness
    • lifestyle
    • Music
    • Nature
    • Podcasts
    • Travel
    • Vlogs
  • Camera
  • Audio
No Result
View All Result
Flyy Tech
No Result
View All Result

Refactoring Existing Code to Use IAM Naming Conventions: Part 3 | by Teri Radichel | Cloud Security | Sep, 2022

flyytech by flyytech
September 7, 2022
Home Security
Share on FacebookShare on Twitter


ACM.44 Ensure group names and policy names are consistent

This is a continuation of my series on Automating Cybersecurity Metrics.

In my last post I explained how to create a reusable template and functions to create IAM users. We can use that same idea to create a reusable function to deploy a group since the only thing I really need to vary in my group template is the name.

I can start with a function to deploy a group.

I can also create a similar function for my group policies with the name of the policy template file matching the name of the policy:

I have the three policy templates in the Policy subdirectory of my Groups/cfn folder:

Here’s the nifty thing. If I always name my CloudFormation policy templates consistently I can easily deploy the policy and the group with a couple extra lines of code. I can calculate the group policy template file name using the group name and deploy it from within the create_group function:

So if my group name is IAMAdmins, then my policy file name will be IAMAdminsGroupPolicy.yaml. I’m not creating a generic policy file because policies are one of the most critical aspects of CloudSecurity and likely each of these will be unique. I add Group to every policy name so I know the policy is associated with a group when looking it up in my list of policies in the AWS console or in the list of CloudFormation stacks.

I decided to keep my group policies in my group folder and this code will prevent group policies from being applied to some other resource — if this is the only code we use to deploy groups and policies. That is another example of how a fully automated environment can help.

Now my deployment script is pretty simple:

Now I can add new groups very quickly and when I want to find them in the CloudFormation console I can simply search on ‘IAM-Group’.

I can easily find policies for groups:

I can find all my IAM administrator templates (though the username would probably match an actual user in a production environment).

Next I can create a generic function to add a user to a group:

In order to test multiple users I’ve added one more user called IAMAdmin2 so I can test adding multiple users to a group. Refer to this post where I add users with similar common functions.

I just added one line to IAM/stacks/Users/deploy.sh:

deploy_user "IAMAdmin2" $profile

Now I can test adding two users to a group in my deploy script:

Check to see that your group has the associated users after creating this stack:

A few caveats about the above deployment script:

Cost

CloudFormation documentation specifies the following for costs:

AWS CloudFormation offers an easy and consistent way to model, provision, and manage a collection of related AWS and third-party resources by treating infrastructure as code. You only pay for what you use, with no minimum fees and no required upfront commitments. When using registry extensions with CloudFormation, you incur charges per handler operation. Handler operations are: CREATE, UPDATE, DELETE, READ, or LIST actions on a resource type and CREATE, UPDATE or DELETE actions for a Hook type. For more information about handler operations and resource providers, please visit the CloudFormation documentation.

This is not exactly clear. What does “When using registry extensions” mean? Well first we can check to see what the CloudForamtion registry is…

The CloudFormation registry lets you manage extensions, both public and private

Are we using an extension here? Is CloudFormation free if we don’t use an extension?

Here’s another item for the #AWSWishList ~ make this documentation clearer.

I don’t believe I’m using extensions and CloudFormation used to be free. The easiest way for me to answer this question is to look at my billing dashboard to see if I’ve been charged anything for CloudFormation in this account. I can confirm that for what I’m doing so far in this repository I am not getting charged any CloudFormation fees. I’ve been using this account and CloudFormation in it for quite some time. In the past, CloudFormation was free, I was just checking to see if that changed.

If you are making use of some kind of extension in addition to what I’m doing here, you might not want to re-run all the stacks just to update one of them. I’m not sure if you would get charged for the execution if there are no updates. The documentation doesn’t say. In the past I’ve had issues with unclear AWS documentation that ended up costing a lot more than initial estimates in a spreadsheet. Hopefully the AWS Calculator would give you more accurate estimates, but it’s still always a good idea to do a proof of concept (POC) and look at your bill before rolling out anything at scale.

If I had pricing concerns and I discovered that I was charged for a call to a stack even when no updates were required, I would create a way to only deploy the specific resources I wanted to change.

Changes in parallel to CloudFormation templates and code

Same as with pricing, you may want to separate out each resource to have its own deployment script when you have a number of things in a repository being updated and you don’t want to deploy unfinished changes. I’m just setting up this repository for testing purposes and the only person in it right now is me. If you had a development team making a number of changes at once you’d likely want to beak up the deployment script.

A change to the validation function

Note that I changed the validation function in stack_functions.sh slightly to pass in the function name.

That way when I report an error I can pass back the function name that had the missing parameter value:

It’s always a good idea to make your error messages as specific as possible to help people quickly pinpoint the source of an error.

Next I added this line to my functions to get the current function name:

function=${FUNCNAME[0]}

Then I pass the function name into the validate_param function.

Passing parameter values to a comma separated list parameter

One other thing that you should know is that when passing comma separated lists to CloudFormation stacks you need to make sure there is no space in the list or you will get an error.

So instead of this:

"IAMAdminUser, IAMAdminUser2"

Pass in this:

"IAMAdminUser,IAMAdminUser2"

Caveats Adding and Removing Users From Groups

I didn’t test removing the IAMAdmin2 user from the group here but I presume removing and redeploying would update the group. What happens if someone removes a user from the group outside the CloudFormation template? I presume redeploying will re-add the user to the group.

What if someone manually adds a user to the group. Is it affected by this stack that adds specific users to the group?

What if we want to output all the users added to the group and use that? Then we have to ensure that the only way the group can be updated is through this automation stack.

On to IAM Roles…

Alright! Now we can very easily create new users, groups, and group policies. We have one more resource to see if we can refactor — IAM Roles. Follow me or sign up for the email list to get that next post.

Teri Radichel

If you liked this story please clap and follow:

Medium: Teri Radichel or Email List: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests services via LinkedIn: Teri Radichel or IANS Research

© 2nd Sight Lab 2022

All the posts in this series:

____________________________________________

Author:

Cybersecurity for Executives in the Age of Cloud on Amazon

Need Cloud Security Training? 2nd Sight Lab Cloud Security Training

Is your cloud secure? Hire 2nd Sight Lab for a penetration test or security assessment.

Have a Cybersecurity or Cloud Security Question? Ask Teri Radichel by scheduling a call with IANS Research.

Cybersecurity & Cloud Security Resources by Teri Radichel: Cybersecurity and Cloud security classes, articles, white papers, presentations, and podcasts





Source_link

flyytech

flyytech

Next Post
Last-Gen RTX 2060 Is Nvidia’s Best GPU Value Right Now

Last-Gen RTX 2060 Is Nvidia's Best GPU Value Right Now

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

When to Use Compression in Your Mix (3 Situations)

When to Use Compression in Your Mix (3 Situations)

March 22, 2023
Do a Powerbomb creator Daniel Warren Johnson illustrates the scary future of corporate consolidation

Do a Powerbomb creator Daniel Warren Johnson illustrates the scary future of corporate consolidation

December 14, 2022

Trending.

Image Creator now live in select countries for Microsoft Bing and coming soon in Microsoft Edge

Image Creator now live in select countries for Microsoft Bing and coming soon in Microsoft Edge

October 23, 2022
Elden Ring best spells 1.08: Tier lists, sorceries, incantations, and locations

Elden Ring best spells 1.08: Tier lists, sorceries, incantations, and locations

January 14, 2023
How to View Ring Doorbell on a Roku TV

How to View Ring Doorbell on a Roku TV

December 20, 2022
Allen Parr’s false teaching examined. Why you should unfollow him.

Allen Parr’s false teaching examined. Why you should unfollow him.

September 24, 2022
Review: Zoom ZPC-1

Review: Zoom ZPC-1

January 28, 2023

Flyy Tech

Welcome to Flyy Tech The goal of Flyy Tech is to give you the absolute best news sources for any topic! Our topics are carefully curated and constantly updated as we know the web moves fast so we try to as well.

Follow Us

Categories

  • Apple
  • Applications
  • Audio
  • Camera
  • Computers
  • Cooking
  • Entertainment
  • Fitness
  • Gaming
  • Laptop
  • lifestyle
  • Literature
  • Microsoft
  • Music
  • Podcasts
  • Review
  • Security
  • Smartphone
  • Travel
  • Uncategorized
  • Vlogs

Site Links

  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

Recent News

New Android Banking Trojan ‘Nexus’ Promoted As MaaS

New Android Banking Trojan ‘Nexus’ Promoted As MaaS

March 23, 2023
Could we Get a OnePlus 11 Special Edition Soon? – Phandroid

Could we Get a OnePlus 11 Special Edition Soon? – Phandroid

March 23, 2023

Copyright © 2022 Flyytech.com | All Rights Reserved.

No Result
View All Result
  • Home
  • Apple
  • Applications
    • Computers
    • Laptop
    • Microsoft
  • Security
  • Smartphone
  • Gaming
  • Entertainment
    • Literature
    • Cooking
    • Fitness
    • lifestyle
    • Music
    • Nature
    • Podcasts
    • Travel
    • Vlogs

Copyright © 2022 Flyytech.com | All Rights Reserved.

What Are Cookies
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT