Comments (12)
Hi @ajithkumar999 thanks for raising the issue.
Did you include all your existing tags and new tags in the --tags
flag?
In my experiment, when I only added new tags and didn't keep any existing tags under --tags
, the deployed result is existing tags got removed. If I keep existing tags under --tags
and add new tags, the deployed resource contains both existing tags and new tags.
Aside, I'd suggest you to use samconfig
to keep your tags. You can define tags as a list instead of a concatenated string and also be able to your existing tags in the config file
example:
[default.deploy.parameters]
capabilities = "CAPABILITY_IAM"
confirm_changeset = true
resolve_s3 = true
tags = [
"aaa=ddd",
"bbb=ccc",
]
from aws-sam-cli.
Hi @hawflau, thanks for looking into this issue
Here my concern is somehow my old tags were missing from the resources, I want to add them back again to the resources, if I add a new tag in the --tags param, it only adds the new tag to the resource, it's not adding the old tags
Please check the below image, only 3 tags were present for the resource, but my sam deploy command has 9 tags init, the team tag which I added newly, how can I add my old tags to the resource?
from aws-sam-cli.
I've tried to reproduce the issue you mentioned. I've created stack with a=1
and b=2
tags. And then I've added c=3
and d=4
tags. After the second deployment I can see all the tags which I've added there. Can you provide more details of your issue?
from aws-sam-cli.
Hello @mndeveci
Thanks for looking into this
let's say the stack has lambda and API gateway resources with these tags a=1 b=2 c=3 and d=4
.
I've manually deleted the tags c=3 and d=4
in the API gateway resource, and lambda has all the required tags.
If I try to re-deploy the stack with the same tags using SAM it's not adding back, if I've modified the tag in the SAM deploy command like d=5
then it will add it back but lambda tags also will get affected.
How can I add the deleted tags back to the resources without affecting the other resources in the stack with the sam deploy command?
from aws-sam-cli.
Hi, just want to reiterate to make sure I'm not getting anything wrong; if I had had deployed tags a=1, b=2
, and I go and delete a=1
from a resource in my stack, I want SAM CLI to be able to deploy the same tags again if I run the exact same sam deploy
command with the same tag argument?
This currently isn't possible since the difference in tags is compared in Cloudformation, not the underlying deployed resources. Since the tags were never modified in the Cloudformation stack, Cloudformation reports that there is nothing to do. The behaviour you see when you update a tag (eg. d=5
in your comment) will update the rest of the resources as expected as the tag comparison is made against the stack, which will have a different d
tag.
You could utilize the AWS CLI or the AWS SDK in the language of your choice to update tags for individual resources, but getting Cloudformation to "reapply" tags won't be possible.
from aws-sam-cli.
Closing issue as Cloudformation doesn't actually check tags in the underlying resources when updating. Feel free to create a new issue for anything else you might discover.
from aws-sam-cli.
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
from aws-sam-cli.
Hi @lucashuy,
can you please reopen this issue
if I had deployed tags a=1, b=2, and I go and delete a=1 from a resource in my stack, I want SAM CLI to be able to deploy the same tags again if I run the exact same sam deploy command with the same tag argument?
Sorry, I should have been more specific in my previous reply. Here’s the exact scenario of what I am facing.
(Note: deployment is through sam deploy, and tags are managed through the --tags flag.)
Day 1: Deploy stack with tags a=1, b=2
.
Expectation: all supported resources in the stack have a=1 and b=2 tags.
Result: as expected.
Day 2: Manually delete b=2
from one of the resources in the stack, say a lambda function.
Expectations: all resources continue to have a=1
and b=2
tags. The lambda function for which we deleted tags only has a=1
tag.
Result: as expected.
Day 3: add c=3
alongside a=1
and b=2
in the --tags flag for sam deploy. Expectations: all supported resources in the stack have a=1, b=2, and c=3 tags including the lambda function for which we earlier deleted the tag.
Result: all resources have a=1, b=2, and c=3
tags. The lambda function only has a=1 and c=3
tag, and b=2
is missing. Because the tag argument is now modified, and there’s a diff, it should update the tags.
from aws-sam-cli.
This would still be Cloudformation specific behaviour that you'd unfortunately come across. Cloudformation won't reapply any tags since it won't do any comparisons against the underlying resources in a stack.
While its true that Lambda does not have b=2
, Cloudformation doesn't care since the stack resource still has b=2
.
from aws-sam-cli.
Hi @lucashuy,
So just to confirm, cloudformation only requests new tag additions for underlying resources. That is, since c=3
was added, stack resource now has a diff and will assign just c=3
to the stack and all resources, and not send the complete list of tags (a=1, b=2 and c=3) to all resources?
from aws-sam-cli.
Hello @lucashuy
is there any update on this? #7050 (comment)
from aws-sam-cli.
Hi, sorry about the delay and back and forth. It looks like the behaviour is that if anything is to change on the stack's tags, all the tags are going to be applied to each of the resources in the stack. So in the previous example that you've noted with the new c=3
, all the tags are going to be reapplied to each resource.
Checking with a sample app shows that all tags are reapplied on any difference, whether that be a new tag or updated tag.
from aws-sam-cli.
Related Issues (20)
- Bug: Docker 4.33 + Provided.al2 Image error HOT 9
- Bug: SAM Deployment Issue: Bootstrap File Not Found Despite Successful Build and Upload HOT 1
- Bug: sam pipeline init - ResourceNotFoundException HOT 1
- Bug: Official example for CDK is not working HOT 1
- Bug: Runtime.ImportModuleError for Typescript Lambda function defined using CDK HOT 2
- Feature request: Run Node tests as part of sam build HOT 2
- Bug: sam build --container-env-var is not working HOT 3
- Thumbprint of the AWS SAM Windows MSI installer does not match the documentation HOT 3
- Bug: ResourceDetailedStatus never returns as part of a cloudformation event HOT 3
- Bug: sam build -u stuck on mounting HOT 9
- Bug: sam local invoke HelloWorld lambda times out on Apple M1 Pro after Sonoma upgrade HOT 2
- Bug: sam validate fails for template using 1.122.0 or 1.223.0 HOT 4
- Feature request: Prune Old Versions HOT 2
- Bug: `sam build` Ignores Files in dist/ Directory When Specified in .gitignore HOT 2
- Bug: DBProxyTargetGroup Creation is very slow when using SAM deploy HOT 3
- Bug: sam build - JSONDecodeError HOT 1
- Bug: `sam init` error: "could not clone repo" (non-zero exit status 128) HOT 10
- Bug: parsing Ref in template.json is incorrect HOT 3
- Bug: sam validate - UnexpectedRuleException HOT 5
- Bug: Numpy In Lambda Layer HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-sam-cli.