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

using the same upstream components multiple times in a project #101

Open
Guslington opened this issue Mar 17, 2019 · 2 comments
Open

using the same upstream components multiple times in a project #101

Guslington opened this issue Mar 17, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Guslington
Copy link
Member

The issue is when you use the same component multiple times that is referencing an upstream component.

For example take a project that manages 2 s3-websites that includes the s3-cloudfront component twice.

CfhighlanderTemplate do
  Name 's3-website'
  Description "s3-website"

  Component name: 's3cloudfront1', template: 's3-cloudfront'
  Component name: 's3cloudfront2', template: 's3-cloudfront'

end

The s3-cloudfront component inlines the cloudfront component with the name hardcoded to cloudfront. https://github.com/theonestack/hl-component-s3-cloudfront/blob/master/s3-cloudfront.cfhighlander.rb#L11

There for the last cloudfront config will overwrite them all causing each s3-website to have the same configuration.

I think the way to resolve this would be to prefix the sub component names with the component name in the project. The same way we handled the config files

s3cloudfront1-cloudfront
s3cloudfront2-cloudfront
@Guslington Guslington added the bug Something isn't working label Mar 26, 2019
@toshke toshke self-assigned this Mar 26, 2019
@aaronwalker
Copy link
Member

aaronwalker commented Mar 27, 2019

@Guslington @toshke yeah I tried to modified the s3-cloudfront component to use the component_name as part of the component name for cloudfront component

something like

  Component name: "#{component_name}-cdn", template: '[email protected]', render: Inline do
    parameter name: "s3bucketOriginDomainName", value: FnGetAtt('Bucket', 'DomainName')
  end

but that didn't help since the issue if the cloudfront is pulling its default config

@rererecursive
Copy link

rererecursive commented May 16, 2019

I just ran into this problem using the s3-cloudfront component. My solution was a bit hacky, but it was to give the CloudFront component a custom name, and then give config block a matching name so that they link. For example, using this config in my project:

bucket_name: my_bucket
cloudfront_component_name: cloudfrontOne
components:
  cloudfrontOne:
    config:
      ...

and these changes to the Highlander component:

  Component name: cloudfront_component_name, template: '[email protected]', render: Inline do
    parameter name: "s3bucketOriginDomainName", value: FnGetAtt('Bucket', 'DomainName')
  end
# defaults
bucket_name: frontend.${EnvironmentName}.${DnsDomain}
cloudfront_component_name: cloudfront
components:
  cloudfront:   # This must match 'cloudfront_component_name'
    config:
      ...

I got it to work.

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

4 participants