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-ecr): ecr.Repository.from_repository_name() method not returning the reference to repository #8652

Closed
rahul-ve opened this issue Jun 19, 2020 · 6 comments
Assignees
Labels
@aws-cdk/aws-ecr Related to Amazon Elastic Container Registry guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@rahul-ve
Copy link

❓ General Issue

The Question

Got the below repo in ECR

{
  "repositoryArn": "arn:aws:ecr:us-east-1:xxxxxxxxxxxx:repository/airflow",
  "registryId": "xxxxxxxxxxxx",
  "repositoryName": "airflow",
  "repositoryUri": "xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/airflow",
  "createdAt": "2020-06-18T05:11:10+10:00",
  "imageTagMutability": "MUTABLE",
  "imageScanningConfiguration": {
      "scanOnPush": false
  }
}

and when building a cdk script, I need to reference this repo, I tried the below:

repo_1 = ecr.Repository.from_repository_name(self, id='airflow_repo', repository_name= 'airflow')
print(repo_1.repository_arn)
print(repo_1.repository_uri)

and the output is:

arn:${Token[AWS::Partition.3]}:ecr:${Token[AWS::Region.4]}:${Token[AWS::AccountId.0]}:repository/airflow
${Token[TOKEN.15]}.dkr.ecr.${Token[TOKEN.14]}.${Token[AWS::URLSuffix.1]}/airflow

below works as expected:

repo_ = ecr.Repository.from_repository_arn(self, id = 'airflow', repository_arn='arn:aws:ecr:us-east-1:xxxxxxxxxxxx:repository/airflow')
print(repo_.repository_arn)
print(repo_.repository_uri)

and the output is:

arn:aws:ecr:us-east-1:xxxxxxxxxxxx:repository/airflow
xxxxxxxxxxxx.dkr.ecr.us-east-1.${Token[AWS::URLSuffix.1]}/airflow

I am using this method incorrectly?
ecr.Repository.from_repository_name()

Environment

  • CDK CLI Version: 1.45.0 (build 0cfab15)
  • Module Version: 1.45.0 (all of them)
  • Node.js Version: v12.17.0
  • OS: Windows 10
  • Language (Version): Python (3.8.2)
@rahul-ve rahul-ve added the needs-triage This issue or PR still needs to be triaged. label Jun 19, 2020
@rahul-ve rahul-ve changed the title (module): (aws-ecr): ecr.Repository.from_repository_name() method not returning the reference to repository Jun 19, 2020
@SomayaB SomayaB added the @aws-cdk/aws-ecr Related to Amazon Elastic Container Registry label Jun 22, 2020
@SomayaB SomayaB added the guidance Question that needs advice or information. label Jun 22, 2020
@MrArnoldPalmer
Copy link
Contributor

@rahul-ve The output looks like its what is expected unless I'm missing something. Is the imported IRepository construct not working as expected when passed to another construct or otherwise breaking your app?

CDK uses a system of Tokens to reference values that may or may not be present during stack synthesis. That is what you're seeing when you print the repository arn of the imported resource.

@rahul-ve
Copy link
Author

rahul-ve commented Jun 29, 2020

@MrArnoldPalmer Using either of the methods allows for proper "synth" but deployment fails when the from_repository_name() method is used. Is there a way to identify the cause?

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jun 29, 2020
@MrArnoldPalmer
Copy link
Contributor

MrArnoldPalmer commented Jun 29, 2020

@rahul-ve what is the error that comes up during deploy?

#8461 - Import doesn't check that the repository exists, doesn't seem like your issue is related to that but worth double checking.

@rahul-ve
Copy link
Author

@MrArnoldPalmer I will have to do another test and cut down my stack to keep it specific. Will report back in the next couple of days.

@SomayaB
Copy link
Contributor

SomayaB commented Sep 3, 2020

Hi @rahul-ve, do you have any updates?

@SomayaB SomayaB added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 3, 2020
@SomayaB SomayaB self-assigned this Sep 3, 2020
@rahul-ve
Copy link
Author

rahul-ve commented Sep 9, 2020

Hi @rahul-ve, do you have any updates?

Sorry, I am unable to spend time on this issue right now, we can close this for now, if I encounter this issue again, will reopen it.
Thank you.

@rahul-ve rahul-ve closed this as completed Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecr Related to Amazon Elastic Container Registry guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants