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

aws: Allow defining blacklist/whitelist of account IDs #1595

Merged
merged 2 commits into from
Apr 22, 2015

Conversation

radeksimko
Copy link
Member

❗ Directly depends on #1594 which should be reviewed & merged separately first.

Closes #1063

This should prevent people (including me) from doing stupid things by simply adding a following line to the provider config:

provider "aws" {
    forbidden_account_ids = ["1234567890"] # live account id
}

or taking the other approach - whitelisting IDs:

provider "aws" {
    allowed_account_ids = ["1234567890"] # dev account id
}

btw. When I was looking at the API response structure, I realised the next step/feature could be allow_root_accounts = true/false if Path = / can help identifying root accounts... but it may not be always accurate, so it would require some further investigation.

$ aws iam get-user
{
    "User": {
        "UserName": "username", 
        "PasswordLastUsed": "2015-02-26T18:40:08Z", 
        "CreateDate": "2015-02-01T13:40:42Z", 
        "UserId": "AAAABBBCCC1234567890", 
        "Path": "/", 
        "Arn": "arn:aws:iam::1111111111111:user/username"
    }
}

 - this will allow defining logically conflicting attributes
@radeksimko
Copy link
Member Author

btw. I wanted to add some tests for Config.ValidateAccountId, but I'm struggling to find any nice approach to mock things in Go.

Some libraries have a direct support, the aws-go-sdk allows defining custom mock endpoints, but it's still far away from a state where I'd just mock a single API endpoint/library like iam.IAM and a single method GetUser which would then always return a static ID.

Mocking the whole library & running a local API server just seem like a way too much overhead, but it could be just my misunderstanding of some Go principles.

@mitchellh
Copy link
Contributor

LGTM. Great job. I think we can turn the []interface{} into []string, but its a nit pick and I can do it myself.

For testing, we should be able to test this... I'll take a stab at it!

mitchellh added a commit that referenced this pull request Apr 22, 2015
aws: Allow defining blacklist/whitelist of account IDs
@mitchellh mitchellh merged commit 3176e5b into hashicorp:master Apr 22, 2015
@radeksimko radeksimko deleted the aws-account-protection branch April 22, 2015 08:20
@ghost
Copy link

ghost commented May 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow defining account ID for provider/aws to prevent human error
2 participants