avatarTeri Radichel

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2622

Abstract

d="ba97">I’ve had a side gig going for many years now as a psychic. Or, more accurately, as a channel.</p><h2 id="aeae">The Last Word</h2><p id="6cbb"><b><i>Hello.</i></b></p><p id="c94e">Ha, you made me laugh.</p><p id="4e6b"><b><i>Well, you were the one who said you were a channel. I thought I’d pop in and say hello.</i></b></p><p id="5ca7">Hi, yourself. We haven’t done this in a while.</p><p id="1a30"><b><i>No, you have been ill. We thought we’d give you an opportunity to heal, as it were.</i></b></p><p id="6254">What do you mean, “as it were”?</p><p id="4b02"><b><i>Healing takes time, especially the older the individual is. You have noticed in the past week that you are able to put your socks on even more easily than before you were sick. You are able to stay up longer hours and are taking an interest in your former activities.</i></b></p><p id="a7d2">Yeah, unfortunately I tanked on NaNoWriMo. Though I still have two days to write before the end of November. I put a good 23,200 words into my third book. I want to finish it off at 30,000 words which is another two or three chapters. I need to go back to the second book and finish that one off with an additional 17,000 words. Then, re-writes on all three books and then think about either turning it over to Dennis to see if he is willing to spend the time editing them or think about hiring an editor to do the job, which I’m thinking would cost a good $3,000 or so which we don’t have. I also need to get up to speed with Canva, or Publisher or re-learn Illustrator to produce some covers. Then, I need to publish the books at KDP and see what happens. I need to drum up some interest in those FaceBook groups I joined and get my author’s website up and running. Anyone who has subscribed to my articles here at Medium will be on the list of folks I approach with book deals and announcements. By the way, if you want to get on that email list <a href="https://pmevanosky.medium.com/subscribe">please subscribe here</a> or email me at <a href="mailto:[email protected]">[email protected]</a>. I suppose I am feeling better. I’ve got a lot to do.</p><p id="6871">Oh, on a less fun note, I need to do our family accounting for 2022. I’m figuring it will take me a couple of months. That means I need the laptop set up next to me with another cordless keyboard to compare Quickbooks 2021 on the laptop with Quickbooks 2022 on the PC. I forget how I classify things from one year to the next. This is the year I have spent money on myself towards publishing books. Can I count those things?</p><p id="3db4"><b><i>Yes, we would say you might create

Options

a publishing classification for yourself. If your accountant wishes to take those expenditures and you use what you earned as a Medium writer this year to offset that would be up to her.</i></b></p><p id="ddb3">But does $48 as income from Medium even come close? I don’t think it counts as more than a hobby.</p><p id="5184"><b><i>Well, is this why you were thinking about side gigs? Perhaps you should concentrate on income-producing side gigs.</i></b></p><p id="b56f">Why are you raining on my parade?</p><p id="426a"><b><i>That’s what you pay us for, though the IRS would never, I guarantee, in a million years count that toward a business expenditure.</i></b></p><p id="afec">Well, I don’t pay you, so there.</p><p id="20eb"><b><i>You do understand what I mean, though.</i></b></p><p id="28fb">Yes, I do. Hey, is anybody going to be remotely interested in this piece?</p><p id="9e6d"><b><i>Time will tell.</i></b></p><p id="a68a">In explanation, <a href="https://medium.com/@pmevanosky/list/the-last-word-where-spirit-speaks-c75cbb677e29"><b><i>The Last Word</i></b></a> is a short conversation between my guide, Seth, and myself that generally has something to do with whatever I am writing about. I’ve started a list of those articles I write where it appears. I hope you enjoy it. I enjoy having Seth and others in Spirit show up occasionally in my pieces. It’s how I channel.</p><p id="3793">If you are not already a Medium member, consider using <a href="https://pmevanosky.medium.com/membership"><b><i>my affiliate link to join</i></b></a>. It is less than <b><i>15¢ a day</i></b>. A small portion of your membership fee will support my writing, and you will have access to all the great articles written by writers on Medium.</p><p id="f2fc">Thanks for reading. <a href="https://pmevanosky.medium.com/subscribe"><b>Subscribe for notifications every time I publish an article</b></a>. See you in the Funny Papers.</p><div id="b2ef" class="link-block"> <a href="https://pmevanosky.medium.com/list/c75cbb677e29"> <div> <div> <h2>The Last Word - Where Spirit Speaks</h2> <div><h3>A section in some of my articles for my Spirit Guide and other interested Folk in Spirit to have a place to talk. Just…</h3></div> <div><p>pmevanosky.medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*cc5922e576207285fd230b798dc9ee73f480108f.jpeg)"></div> </div> </div> </a> </div></article></body>

Refactoring Existing Code to Use IAM Naming Conventions: Part 3

ACM.44 Ensure group names and policy names are consistent

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⚙️ Check out my series on Automating Cybersecurity Metrics. The Code.

🔒 Related Stories: IAM | AWS Security | Application Security

💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

Follow for updates.

Teri Radichel | © 2nd Sight Lab 2022

About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
Iam
Groups
Cloudformation
Policy
Cloudsecurity
Recommended from ReadMedium