-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
243 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/YaleSpinup/aws-go/services/iam" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// orgTagAccessPolicy generates the org tag conditional policy to be passed inline when assuming a role | ||
func orgTagAccessPolicy(org string) (string, error) { | ||
log.Debugf("generating org policy document") | ||
|
||
policy := iam.PolicyDocument{ | ||
Version: "2012-10-17", | ||
Statement: []iam.StatementEntry{ | ||
{ | ||
Effect: "Allow", | ||
Action: []string{"*"}, | ||
Resource: []string{"*"}, | ||
Condition: iam.Condition{ | ||
"StringEquals": iam.ConditionStatement{ | ||
"aws:ResourceTag/spinup:org": []string{org}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
j, err := json.Marshal(policy) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return string(j), nil | ||
} | ||
|
||
func sgDeletePolicy(id string) (string, error) { | ||
log.Debugf("generating org policy document") | ||
|
||
sgResource := fmt.Sprintf("arn:aws:ec2:*:*:security-group/%s", id) | ||
|
||
policy := iam.PolicyDocument{ | ||
Version: "2012-10-17", | ||
Statement: []iam.StatementEntry{ | ||
{ | ||
Effect: "Allow", | ||
Action: []string{ | ||
"ec2:DeleteSecurityGroup", | ||
}, | ||
Resource: []string{sgResource}, | ||
}, | ||
}, | ||
} | ||
|
||
j, err := json.Marshal(policy) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return string(j), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.