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

Fix for parsing of existing IAM policy #1

Merged
merged 1 commit into from
Nov 30, 2015
Merged

Conversation

jbrook
Copy link
Contributor

@jbrook jbrook commented Nov 30, 2015

During provisioning I was running into an error when trying to check for an existing SNS permission policy. I have code like this to define the permission:

lambdaWelcome := sparta.NewLambda(roleDefinition, sendWelcomeEmail, welcomeOptions)

  lambdaWelcome.Permissions = append(lambdaWelcome.Permissions, sparta.SNSPermission{
    BasePermission: sparta.BasePermission{
      SourceArn: "arn:aws:sns:eu-west-1:7056640223706:development__global__user__didJoin",
    },
  })

And I was getting the following error:

DEBU[0016] Ensuring IAM Role results                     Principal=sns.amazonaws.com PrincipalActions=[sns:ConfirmSubscription sns:GetTopicAttributes sns:Subscribe sns:Unsubscribe]
panic: interface conversion: interface {} is nil, not sparta.ArbitraryJSONObject

goroutine 1 [running]:
github.com/mweagle/Sparta.ensureIAMRoleResource(0x728db0, 0x11, 0x7ac2a0, 0x4c, 0xc820112750, 0xc820076e40, 0x0, 0x0, 0x0, 0x0)
  /Users/jbrook/go-projects/src/github.com/mweagle/Sparta/provision_utils.go:107 +0x15b0
github.com/mweagle/Sparta.ensureConfiguratorLambdaResource(0x728db0, 0x11, 0x7ac2a0, 0x4c, 0xc820112750, 0x7fff5fbff72b, 0x19, 0xc82000a163, 0x17, 0xc820076e40, ...)
  /Users/jbrook/go-projects/src/github.com/mweagle/Sparta/provision_utils.go:46 +0xf8

It seems like the structure coming back for the resource in my case was rather different from what the code was expecting.

@mweagle
Copy link
Owner

mweagle commented Nov 30, 2015

@jbrook - Thanks for the writeup & PR. Writing up a test case to enforce and will merge shortly. Cheers.

mweagle added a commit that referenced this pull request Nov 30, 2015
Include test to demonstrate #1
@mweagle
Copy link
Owner

mweagle commented Nov 30, 2015

Looks good - locally confirmed error & PR fix with bd98a64. Merging.

mweagle added a commit that referenced this pull request Nov 30, 2015
Fix for parsing of existing IAM policy
@mweagle mweagle merged commit 1d23245 into mweagle:master Nov 30, 2015
mweagle pushed a commit that referenced this pull request Jan 25, 2018
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.

2 participants