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

Error while deploying Community::Organizations::EnableAWSServiceAccess #74

Open
eduardomourar opened this issue Jan 26, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@eduardomourar
Copy link
Member

If you try to enable the AWS service access for access-analyzer.amazonaws.com, the following error happens in Community::Organizations::EnableAWSServiceAccess resource type v0.1.0:

Properties validation failed for resource AccessAnalyzerServiceAccess with message: #: required key [ResourceId] not found

@eduardomourar eduardomourar added the bug Something isn't working label Jan 26, 2021
@sshvetsov
Copy link
Contributor

This error still appears today.

_tasks.yml::

AccessAnalyzer:
  Type: update-stacks
  Template: ./access-analyzer.yml
  StackName: !Sub '${resourcePrefix}-access-analyzer'
  MaxConcurrentStacks: 10
  Parameters:
    targetId: !Ref SectoolsAccount
  OrganizationBindings:
    ManagementAccountBinding:
      IncludeMasterAccount: true
      Region: !Ref globalRegion

access-analyzer.yml:

AWSTemplateFormatVersion: '2010-09-09-OC'

OrganizationBindings:
  # Binding for:
  ManagementAccountBinding: # null = empty binding

Parameters:
  targetId:
    Type: String

Resources:
  AccessAnalyzerServiceAccess:
    Type: 'Community::Organizations::EnableAWSServiceAccess'
    OrganizationBinding: !Ref ManagementAccountBinding
    Properties:
      ServicePrincipal: access-analyzer.amazonaws.com

  AccessAnalyzerDelegatedAdmin:
    Type: 'Community::Organizations::DelegatedAdmin'
    DependsOn: AccessAnalyzerServiceAccess
    OrganizationBinding: !Ref ManagementAccountBinding
    Properties:
      ServicePrincipal: access-analyzer.amazonaws.com
      AccountId: !Ref targetId

Error message:

ERROR: error updating CloudFormation stack prefix-access-analyzer in account 1234 (us-east-1).
Resource is not in the state stackCreateComplete (1234 = ManagementAccount)
ERROR: Resource AccessAnalyzerServiceAccess failed because Properties validation failed for resource AccessAnalyzerServiceAccess with message:
#: required key [ResourceId] not found.
ERROR: Stack prefix-access-analyzer in account 1234 (us-east-1) update failed. reason: Resource is not in the state stackCreateComplete (1234 = ManagementAccount)
Resource is not in the state stackCreateComplete (use option --print-stack to print stack)

@OlafConijn
Copy link
Member

hi @sshvetsov ,

thanks for reaching out!
i haven't looked into why this is required, but using 0.1.0 it indeed seems you would need to provide a ResourceId.
example:

  AccessAnalyzerServiceAccess:
    Type: 'Community::Organizations::EnableAWSServiceAccess'
    OrganizationBinding: !Ref ManagementAccountBinding
    Properties:
      ServicePrincipal: access-analyzer.amazonaws.com
      ResourceId: enable-access-analyzer

Looking at the aws service call for aws organizations enable-aws-service-access this indeed seems like something that should not be necessary. providing it in the properties can be used as a workaround until fixed

@sshvetsov
Copy link
Contributor

sshvetsov commented Jan 6, 2023

Thanks a bunch for describing the ResourceId workaround. It works like a charm!
It's listed as required property in the docs, but I have completely missed it because it was not shown in the example.yml.

I've submitted PR #114 to fix the example.yml file.

I've also submitted PR org-formation/org-formation-reference#46 to the org-formation-reference repo to fix the AccessAnalyzer example there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants